Can time spent living as renter prior to owning a home count as principal residence "use" time towards 2 years required for capital gains tax exclusion upon later sale?

Can the 2 year time periods at 26 USC 121 be met at different times?  If I lived in a rental property for a year before owning it (year 1), can I move out after 2 years of living in it and one year after owning it (year 2) and then sell it in/after year 3 and meet the 2 years of use and ownership required for the capital gains tax exclusion upon sale of a principal residence?