Deductions & credits

Hello!  I'm in a similar situation.  My spouse & I bought House A (primary residence) in August 2020, then sold it in September 2022.  Box 2 of A's Form 1098 says ~$737,000.  We bought House B (secondary residence which became our primary residence when A was sold) in July 2022.  Box 2 of B's Form 1098 says ~$594,000.  Can we deduct the entire amount of mortgage interest on both houses?  Or is the deductible amount limited because the sum of mortgages exceeds $750,000?  Even if our held mortgages only exceeded that amount for a couple of months?  If so, what is the appropriate formula to calculate the deductible portion of mortgage interest?  Thanks!