Wa `alaykum As-Salamu waRahmatullahi wa Barakatuh.
In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
Answering your question, Dr. Mohammad S. Alrahawan, Associate Professor at the department of Islamic Studies in English, Al-Azhar University, Egypt, states:
If you miss a constituent element of prayer such as ruku or a prostration and you discover this subtract before making your final tasleem, just add a new rakah and recite tashahhud and tasleem. At the end, you should make sujud as-sahaw (prostration for being forgetful).
But if you discover that immediately after tasleem, you can add a full rakah and recite tashahhud and tasleeem in addition to two prostrations for forgetfulness.
However, in case you miss a supererogatory act of prayer such as the middle tashahhud of a prayer consisting of four rakahs, you just make two prostrations for forgetfulness.
Allah Almighty knows best.