According to this Timeline of the Far Future [0], we only have 500-600 million years.

(warning, this is one of the most depressive pages on Wikipedia)

[0]: https://en.wikipedia.org/wiki/Timeline_of_the_far_future

You confused two things. There is the Sun turning into red giant in 5 billion years consuming the Earth, and the Sun getting too bright for Earth to be habitable in 500 million years.