Praise be to Allaah.
In the case of doubt as to the number of rak’ahs, one should
act on the basis of what is certain, so he should assume the smaller number
of rak’ahs. So if he acts according to what is more likely, i.e., what he
thinks is most likely to be the case, even by looking at those who are next
to him, there is nothing wrong with that, provided that he does sujood
al-sahw (prostration of forgetfulness) in either case.
Shaykh ‘Abd al-Kareem al-Khudayr.