Wells Fargo & Co.’s sale of 52 branches to Flagstar Bancorp Inc. marks a retail-banking exit from Indiana, Michigan and Ohio.

The deal is part of Wells Fargo’s effort to reduce its branch count to about 5,000 from roughly 5,800 by the end of 2020, the company said Tuesday in a statement.

Flagstar plans to acquire 33 Wells Fargo branches in Indiana, with 26 of them in the Fort Wayne area and the rest in the South Bend area.

Almost 500 employees will be get job offers from Flagstar.

“Wells Fargo will continue to have a presence in the area with other businesses including commercial lending, wealth management, retail brokerage, and home lending,” Mary Mack, head of community banking and consumer lending for the company, said in the statement.

The Flagstar deal, which also includes four branches in Wisconsin, features $2.3 billion in deposits and $130 million in loans, according to a separate statement from Flagstar. Troy, Michigan-based Flagstar will pay a 7 percent deposit premium, amounting to about $161 million.

“This is opportunism at its best -– a win-win for Wells Fargo,” Susan Katzke, an analyst at Credit Suisse Group AG, said in a note. “Wells Fargo can generate replacement deposits, as needed, at a lower cost than maintaining this physical presence.”

San Francisco-based Wells Fargo isn’t among the top 10 banks in any of the three states it’s leaving, based on deposit totals. It’s No. 1 in California.

The sale is unrelated to an asset cap imposed by the Federal Reserve that limits the lender’s growth until it fixes compliance and consumer-related missteps, according to Mary Eshet, a spokeswoman for the bank.

The Midwest retreat contrasts with plans by Bank of America Corp., which said in February it would open 500 branches across the U.S. during the next four years, including an expansion in Ohio. Bank of America jumped ahead of Wells Fargo to become the U.S. bank with the second-largest deposit base in 2017, according to Federal Reserve data. JPMorgan Chase & Co. is first.