حَدَّثَنَا سُفْيَانُ بْنُ وَكِيعٍ، حَدَّثَنَا يُونُسُ بْنُ بُكَيْرٍ، حَدَّثَنَا ابْنُ إِسْحَاقَ، حَدَّثَنِي الزُّهْرِيُّ، عَنْ أَبِي سَلَمَةَ، عَنْ أَبِي هُرَيْرَةَ، أَنَّ النَّبِيَّ ـ صلى الله عليه وسلم ـ قَالَ ‏"‏ إِنَّ الشَّيْطَانَ يَأْتِي أَحَدَكُمْ فِي صَلاَتِهِ، فَيَدْخُلُ بَيْنَهُ وَبَيْنَ نَفْسِهِ حَتَّى لاَ يَدْرِي زَادَ أَوْ نَقَصَ. فَإِذَا كَانَ ذَلِكَ، فَلْيَسْجُدْ سَجْدَتَيْنِ قَبْلَ أَنْ يُسَلِّمَ. ثُمَّ يُسَلِّمْ ‏"‏ ‏.‏
Translation
It wasnarrated from Abu Hurairah that the Prophet (ﷺ) said

“TheSatancomes between the son of Adam and his soul, and he does not knowhowmany Rak’ah he has prayed. If a person notices that, then let himprostrate twice before he says the Salam.”