Hadith 562
سئل عن رجل سها فى صلاته فلم يدركم صلى قال ليعد صلاته و ليسجد سجدتين
The Messenger of Allah (peace be upon him) was asked about a person who forgets how many units of prayer he has performed during the prayer. He (peace be upon him) said: He should repeat the prayer and perform two prostrations while sitting.