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.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الخلع والطلاق / Q15135