Sahih Muslim , Hadith 571

Abu Sa'id al-Khudri reported: The Messenger of Allah said: When any one of you is in doubt about his prayer and he does Dot know how much he has prayed, three or four (rak'ahs). he should cast aside his doubt and base his prayer on what he is sure of. then perform two prostrations before giving salutations. If he has prayed five rak'ahs, they will make his prayer an even number for him, and if he has prayed exactly four, they will be humiliation for the devil.

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

sunnah.com

This hadith has been narrated by Zaid b. Aslam with the same chain of transmitters and he said: He should perform two prostrations before the salutation, as it was mentioned by Sulaiman b. Bilal.

حَدَّثَنِي أَحْمَدُ بْنُ عَبْدِ الرَّحْمَنِ بْنِ وَهْبٍ، حَدَّثَنِي عَمِّي عَبْدُ اللَّهِ، حَدَّثَنِي دَاوُدُ بْنُ قَيْسٍ، عَنْ زَيْدِ بْنِ أَسْلَمَ، بِهَذَا الإِسْنَادِ وَفِي مَعْنَاهُ قَالَ ‏ "‏ يَسْجُدُ سَجْدَتَيْنِ قَبْلَ السَّلاَمِ ‏" ‏ ‏.‏ كَمَا قَالَ سُلَيْمَانُ بْنُ بِلاَلٍ ‏.‏

sunnah.com