Sayyiduna Abu Sa'id al-Khudri (may Allah be pleased with him) said that the Messenger of Allah (peace and blessings be upon him) said: "When one of you does not know whether he has prayed three rak'ahs or four, he should complete the prayer and pray one more rak'ah. Then after that he should perform the two prostrations of forgetfulness while sitting. If his rak'ahs have become five, his prayer will become even because of these prostrations, and if his rak'ahs are four, then these two prostrations will be a cause of humiliation and disgrace for Satan."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 3803