The World Federation One Stop Fiqh

Ruling 1196

If after prayers one doubts that while performing the prayer he doubted about, for example, whether he had performed two or four rakʿahs, or three or four rakʿahs, then 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.