AssalamoAlikum Brother,
If you feel insecure and forget how many rakaat you offered during Namaz then please when you start your Namaz you think of Allah only that time and pay your full attention on prayer ,i believe then you would never forget any thing in Namaz...