Messenger of Allah ﷺ said, "When anyone of you stands for the prayers, Satan comes and puts him in doubts till he forgets how many rakʿat he has prayed. So if this happens to anyone of you, he should perform two prostrations of Sahu while sitting.
أَنَّ رَسُولَ اللَّهِ ﷺ قَالَ إِنَّ أَحَدَكُمْ إِذَا قَامَ يُصَلِّي جَاءَ الشَّيْطَانُ فَلَبَسَ عَلَيْهِ حَتَّى لاَ يَدْرِيَ كَمْ صَلَّى فَإِذَا وَجَدَ ذَلِكَ أَحَدُكُمْ فَلْيَسْجُدْ سَجْدَتَيْنِ وَهُوَ جَالِسٌ