Anas bin Malik reported,

The Prophet ﷺ said, "If one of you is uncertain about his prayer and does not know whether he has prayed two or three units, let him cast aside the doubt and build upon what he is certain of."

Azami 2474

Sahih

عن أنس

عن النبي ﷺ قال: إذا شك أحدكم في صلاته فلم يدر اثنين صلى، أو ثلاثا، فليلق الشك، وليبن على اليقين.

الأعظمي 2474صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Prayer
Chapter
Forgetfulness
Section
Two prostrations for forgetfulness and building upon certainty
Numbering
Jami al-Kamil 2474 (2nd edition)
Azami 2474