The World Federation One Stop Fiqh

Ruling 1196

If after prayers one doubts that while performing the prayer he had a doubt about, for example, whether he had performed two or four rakʿahs, or three or four rakʿahs, in such a case, he can act according to the instructions relating to both doubts, and after doing something that invalidates prayers, he can perform the prayer again.