Sayyiduna Abu Bakrah (may Allah be pleased with him) narrates from the Prophet (peace and blessings be upon him) that the Prophet (peace and blessings be upon him) led these in two rak'ahs and the others in two rak'ahs as well. So for the Prophet (peace and blessings be upon him) it came to four rak'ahs, and for them two rak'ahs each.
Imam al-Shafi'i (may Allah have mercy on him) says: The rak'ahs of the last of the two groups will count as obligatory for them and voluntary for the Prophet (peace and blessings be upon him).
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 5109