The Messenger of Allah ﷺ said, "Satan comes to one of you during his prayer and confuses him until he does not know how many units he has prayed. When one of you finds himself in this state, let him perform two prostrations while seated."
حدثنا قتيبة حدثنا الليث عن ابن شهاب عن أبي سلمة
قال رسول الله ﷺ إن الشيطان يأتي أحدكم في صلاته فيلبس عليه حتى لا يدري كم صلى فإذا وجد ذلك أحدكم فليسجد سجدتين وهو جالس
Agreed upon [by Bukhari and Muslim]. Muslim narrated it in the Book of Mosques, chapter on forgetfulness in prayer and the sujud for it, hadith no. 82/389, from Qutayba, and Bukhari, hadith no. 1232, from the hadith of Ibn Shihab Zuhri, with the same wording.