Bank of America Corp. thought it had a bargain four years ago when it paid $2.5 billion for tottering mortgage lender Countrywide Financial Corp., but the purchase has already cost the Charlotte, N.C., lender more than $40 billion in real-estate losses, legal expenses and settlements with state and federal agencies, the Wall Street Journal reported today. The acquisition of Countrywide, which was completed almost exactly four years ago, turned Bank of America into a huge mortgage lender just as the U.S. housing market collapsed. Current Bank of America CEO Brian Moynihan, who took over in 2010, has acknowledged that his bank purchased Countrywide "just when you shouldn't have done it."