Get your taxes done using TurboTax

@JeffreyR77 This is the closest example I can find on the IRS website, although the "6-year lookback rule" doesn't seem to apply to F-1 students:

 

Example 9
D was a citizen and resident of a foreign country just prior to her arrival in the United States. She arrived in the United States for the first time ever on 08-15-2013 as a student on an F-1 visa. She remained in F-1 status until she graduated in June 2018. She left the United States on 06-30-2018 and returned home. On 08-01-2019 she returned to the United States as a researcher on a J-1 visa. Determine her residency starting date for her most recent visit.

Solution:
Analysis for 2019
Date of (second) entry into United States: 08-01-2019
Exempt individual: 08-15-2013 through 12-31-2017
Nonexempt individual: 01-01-2018 through 06-30-2018 and 08-01-2019 through 12-31-2019

Begin counting days of presence in the United States on 08-01-2019. Because D is currently a J-1 non-student, apply the 6-year “lookback rule”. Because she had already been an exempt individual as an F-1 student during 2 of the 6 years prior to 2019, she cannot be an exempt individual during 2019 and must start counting days of presence on the date of her arrival in the United States. During her prior visit as an F-1 student, applying the 5-year rule, she ceased to be an exempt individual on 12-31-2017.

Number of nonexempt days in United States during 2019: 153 days (08-01-2019 through 12-31-2019)

 

https://www.irs.gov/individuals/international-taxpayers/alien-residency-examples