Abu Hurairah reported,

The Messenger of Allah ﷺ said, "When the call to prayer is made, Satan turns away passing wind so that he does not hear the adhan. When the adhan is finished, he comes back. When the iqamah is called, he turns away again, and when the iqamah is finished, he returns and slips between a man and his own self, saying, 'Remember this, remember that,' bringing to mind things the man had not been thinking about, until he is left not knowing how much he has prayed. So if any of you does not know whether he has prayed three or four, let him perform two prostrations while seated."

Bukhari 1231

Sahih

حدثنا معاذ بن فضالة حدثنا هشام بن أبي عبد الله الدستوائي عن يحيى بن أبي كثير عن أبي سلمة

عن أبي هريرة رضي الله عنه قال

قال رسول الله ﷺ إذا نودي بالصلاة أدبر الشيطان وله ضراط حتى لا يسمع الأذان فإذا قضي الأذان أقبل فإذا ثوب بها أدبر فإذا قضي التثويب أقبل حتى يخطر بين المرء ونفسه يقول اذكر كذا وكذا ما لم يكن يذكر حتى يظل الرجل إن يدري كم صلى فإذا لم يدر أحدكم كم صلى ثلاثا أو أربعا فليسجد سجدتين وهو جالس

البخاري 1231صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Forgetfulness
Chapter
If one does not know whether he prayed three or four, he should prostrate twice while sitting
Numbering
Darussalam 1231
Bukhari 1231