«إذا شك أحدكم في صلاته فلم يدر اثنتين صلى أو ثلاثا فليلق الشك وليبن على اليقين»
The Prophet (peace and blessings be upon him) said:
"When one of you is in doubt in his prayer and does not know whether he has prayed two rak'ahs or three, let him cast aside the doubt and build on what is certain (that is, the lower number)."
Hadith Referenceصحیح الجامع الصغیر / حرف الألف / 631