One may begin to fast even in a state of ritual impurity
BUKHARI 1925:
from Abū Bakr b. ʿAbd al-Raḥman —
At times Messenger of Allah ﷺ used to get up in the morning in the state of Janaba after having sexual relations with his wives. He would then take a bath and fast.
البخاري ١٩٢٥:
عن ابو بكر بن عبد الرحمن —
أَنَّ رَسُولَ اللَّهِ ﷺ كَانَ يُدْرِكُهُ الْفَجْرُ وَهُوَ جُنُبٌ مِنْ أَهْلِهِ ثُمَّ يَغْتَسِلُ وَيَصُومُ