Abu Saeed Khudri reported,

The Messenger of Allah ﷺ said, "When one of you is uncertain during his prayer and does not know how much he has prayed, whether three units or four, let him cast aside the doubt and proceed on what he is certain of, then perform two prostrations before giving the closing salutation. If he had in fact prayed five units, these prostrations will make his prayer an even number for him, and if he had prayed a complete four units, they will be a humiliation for Satan."

Azami 2471

Sahih

عن أبي سعيد الخدري قال

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

الأعظمي 2471صحيح
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 2471 (2nd edition)
Azami 2471