Primary Residence Cap Gains

Greetings!  I have read Section 121 backwards and forwards. 

I need help understanding the 2 out of 5 year exclusion for capital gains. 

My wife and I bought our house in January 2018 and used it exclusively as our primary residence for 2 years and 1 month.  We sold it in February 2020 for a gain of $400,000.

Since we lived in it as our primary residence for 2 years do we qualify for exclusion of capital gains tax? Or did we need to own the residence for a total of 5 years before getting that exclusion?

 

Thank you for your help!!!