With the middle-class squeezed by the rising cost of living, particularly housing costs, many average-earners find it an onerous endeavor to create a decent life for themselves and their families. Living in a big metro like New York or Los Angeles may come with a high income and more opportunities, but the cost of housing in these expensive areas can place a middle-class lifestyle too far out of reach.

The data itself tells the story. The average monthly rent in Manhattan is around $4,100, which represents a crushing 59% of the area’s median household income ($83,500), and the median cost of a home in the borough is $1.1M, 13 times the median income. The price to income ratio is a commonly used indicator of how much house one can afford and the recommended ratio is 2.6. Another example is Los Angeles County, where the rent costs on average $2,100 per month or 38% of income, and the median price of a home is around $630,000, almost 10 times the median yearly income of $66,000 in this area.

One solution to this issue is to move, so we decided to take a look at population movements within the U.S., using the most recent U.S. Census county-level population data. According to the U.S. Census Bureau, around 55% of those who decide to move do so for a housing-related reason, such as to relocate to a new or better home, to find cheaper housing, or to own their home instead of rent.

Maricopa County tops the list of desirable places to relocate with a 221,000 net population increase via domestic migration between 2012 and 2017.

The median household income in the Phoenix area is around 63,000, only about $3,000 less than that in Los Angeles metro ($66,000). Meanwhile, the rent is $1,000 per month cheaper in Phoenix.

To figure out which counties saw the largest net changes in population due to moving in or out of the county, RentCafe subtracted the total outbound domestic migration from the total inbound domestic migration over a five-year period between 2012 and 2017. As such, we came up with the list of counties where domestic migration over a 5-year period translated into the highest net gain in population versus the counties where domestic migration brought about the highest net loss of population over the same period of time. This analysis looks strictly at resident population movements (domestic migration) across county lines, and does not include international migration (immigration) or natural population changes due to natality or mortality.

Moving away from an expensive, so-called first-tier metro to a more affordable second-tier metro is a major trend frequently referred to as “affordable migration.” Here’s a side-by-side look at the top 10 counties Americans are leaving and the top 10 counties Americans are moving to: