I own a townhouse in Virginia since 2001 and rented from 2008 to now. We return to US in 2025 and plan to sell for medical reasons. How to calculate Cap Gains exclusion?

We want to determine our partial exclusion (out of 500,000 max for joint filing) using medical reason (my wife can no longer handle stairs). How do we determine if and by how to calculate the partial exclusion.