The Messenger of Allah ﷺ said, "When one of you stands to pray, Satan comes to him and confuses him until he does not know how many units he has prayed. When any of you experiences that, let him perform two prostrations while seated."
حدثنا القعنبي عن مالك عن ابن شهاب عن أبي سلمة بن عبد الرحمن
أن رسول الله ﷺ قال إن أحدكم إذا قام يصلي جاءه الشيطان فلبس عليه حتى لا يدري كم صلى فإذا وجد أحدكم ذلك فليسجد سجدتين وهو جالس
Bukhari narrated it in the Book of Forgetfulness, in the chapter on forgetfulness in obligatory and voluntary prayers, hadith no. 1232, and Muslim narrated it in the Book of Prayer, in the chapter on the merit of the adhan and the fleeing of Satan upon hearing it, hadith no. 389, after hadith no. 569, from the hadith of Malik through this same chain. It is also found in Muwatta (Yahya) 1/100, and (Qanabi, pp. 178, 179), p. 178.