It is narrated from Sayyiduna Anas (may Allah be pleased with him) that the Prophet (peace and blessings be upon him) said: "When one of you has a doubt about his prayer and does not know whether he has prayed two or three, let him discard the doubt and act upon certainty."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3808
Hadith Gradingمحدثین:صحيح لغيره
Hadith Takhrij«صحيح لغيره۔ وقد تقدم الكلام عليه في رقم 3804»