Imam al-Shafi'i (may Allah have mercy on him) said: "The (second) husband who has intercourse with her after three divorces cancels (the previous divorces), but he does not cancel one or two divorces." And he cited as evidence the following.
Sayyiduna Abu Hurayrah (may Allah be pleased with him) says: I asked Sayyiduna Umar (may Allah be pleased with him) about a man from the people of Bahrain who had given his wife one or two divorces; the woman then married another husband, who died or divorced her. Then she returned to her first husband: how many divorces remain for him? He said: As many divorces as were left the first time, those remain.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الخلع والطلاق / 15135