أَخْبَرَنَا قُتَيْبَةُ، عَنْ مَالِكٍ، عَنِ ابْنِ شِهَابٍ، عَنْ أَبِي سَلَمَةَ، عَنْ أَبِي هُرَيْرَةَ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَالَ ‏"‏ إِنَّ أَحَدَكُمْ إِذَا قَامَ يُصَلِّي جَاءَهُ الشَّيْطَانُ فَلَبَسَ عَلَيْهِ صَلاَتَهُ حَتَّى لاَ يَدْرِي كَمْ صَلَّى فَإِذَا وَجَدَ أَحَدُكُمْ ذَلِكَ فَلْيَسْجُدْ سَجْدَتَيْنِ وَهُوَ جَالِسٌ ‏"‏ ‏.‏

It was narrated from Abu Hurairah that: The Messenger of Allah (PBUH) said: "When any one of you gets up and prays, the Shaitan comes to him an confuses him until he does not know how many (Rak'ahs) he prayed. If any one of you notices that, let him prostrate twice when he is sitting." Translation Not Available

Book Ref: Sunan An Nisai Book 13 Hadith 1252
Web Ref:  Sunan An Nisai Vol 2 Book 13 Hadith 1253