Yahya related to me from Malik from Zayd ibn Aslam from Ata ibn
Yasar that the Messenger of Allah, may Allah bless him and grant him
peace, said, "If you are uncertain in the prayer and do not know
whether you have prayed three or four rakas, then pray a raka and make
two prostrations from the sitting position before the taslim. If the
raka that you prayed was the fifth, then you make it even by these two
sajdas, and if it was the fourth, then the two prostrations spite
Shaytan."
Muwatta Malik Book 3, Hadith 66