Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him) said: "When one of you bows and reaches the row before they raise their heads, he should count that rak'ah; and if they raise their heads before he reaches the row, he should not count it."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 9325