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
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
Imam al-Zuhri (may Allah have mercy on him) narrates it with his chain and its meaning, except that he said: Then her iddah ended and another man married her. Al-Humaydi (may Allah have mercy on him) says: Sufyan (may Allah have mercy on him) was told that Sa'id bin al-Musayyib (may Allah have mercy on him) was among them (the narrators). He said: Al-Zuhri narrated it to us like this; he did not give us more than these three. When he had finished with it, he said: I do not remember Sa'id in it from al-Zuhri, but Yahya bin Sa'id narrated to us from Sa'id, from Sayyiduna Abu Hurayrah (may Allah be pleased with him), something similar, and that suffices you.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الخلع والطلاق / 15136
Mazidah narrates from his father that Sayyiduna Ali (may Allah be pleased with him) said: That woman will remain with him on the basis of the divorces that remain to him. Sa'id says: Qatadah adopted this view, concerning a man who gives his wife one or two divorces, then she marries (another), then that man takes her back.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الخلع والطلاق / 15137
أَخْبَرَنَا أَبُو مُحَمَّدِ بْنُ يُوسُفَ، أنا أَبُو سَعِيدِ بْنُ الْأَعْرَابِيِّ، نا الزَّعْفَرَانِيُّ، نا أَبُو عَبَّادٍ، نا شُعْبَةُ، نا الْحَكَمُ، عَنْ مَزِيدَةَ بْنِ جَابِرٍ، عَنْ أَبِيهِ، أَنَّهُ سَمِعَ عَلِيًّا رَضِيَ اللهُ عَنْهُ يَقُولُ: " هِيَ عِنْدَهُ عَلَى مَا بَقِيَ ".
Mazidah bin Jabir (may Allah have mercy on him) narrates from his father that he heard Sayyiduna Ali (may Allah be pleased with him) saying: This woman will remain with the man on the basis of the remaining divorces.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الخلع والطلاق / 15138
Abdur-Rahman bin Abi Layla (may Allah have mercy on him) narrates from Sayyiduna Ubayy bin Ka'b (may Allah be pleased with him) that this woman will remain with her husband on the basis of the remaining divorces; that is, a man who divorced his wife so that she became separated from him, then she married another husband, who also divorced her, then the first husband married her again: she will remain with the first husband on the basis of the remaining divorces.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الخلع والطلاق / 15139
أَخْبَرَنَا أَبُو بَكْرٍ الْأَصْبَهَانِيُّ، أنا أَبُو نَصْرٍ الْعِرَاقِيُّ، نا سُفْيَانُ بْنُ مُحَمَّدٍ، نا عَلِيُّ بْنُ الْحَسَنِ، نا عَبْدُ اللهِ بْنُ الْوَلِيدِ، نا سُفْيَانُ، نا خَالِدٌ الْحَذَّاءُ، عَنِ ابْنِ سِيرِينَ، عَنْ عِمْرَانَ بْنِ حُصَيْنٍ قَالَ: " هِيَ عَلَى مَا بَقِيَ مِنَ الطَّلَاقِ " وَرُوِيَ عَنِ ابْنِ عُمَرَ وَابْنِ عَبَّاسٍ رَضِيَ اللهُ عَنْهُمَا بِخِلَافِ ذَلِكَ.
Ibn Sirin (may Allah have mercy on him) narrates from Sayyiduna Imran bin Husayn (may Allah be pleased with him) that this woman will remain with her first husband on the basis of the remaining divorces only.
The opposite of this has been reported from Abdullah bin Umar and Abdullah bin Abbas (may Allah be pleased with them).
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الخلع والطلاق / 15140
Wabarah narrates from Sayyiduna Abdullah bin Umar (may Allah be pleased with them both): When a man gives his wife one or two divorces, then another man marries that woman, then the first husband marries her again, he is entitled to three divorces anew.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الخلع والطلاق / 15141
Tawus narrates from Sayyiduna Abdullah bin Abbas (may Allah be pleased with them both) concerning a man who gives his wife two divorces, then some man marries that woman, then he divorces her or dies, then her first husband marries her: he will now have the right to three divorces.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الخلع والطلاق / 15142
Muhammad bin al-Hanafiyyah narrates from Sayyiduna Ali (may Allah be pleased with him) concerning a man who gave his wife one or two divorces, then she married another husband, who also divorced her, then she came back to the first husband: after (her) marriage (to another), he begins the divorces anew; but if he married her during her iddah, she will remain with him on the basis of the remaining divorces.
The first narration from Ali (may Allah be pleased with him) is more authentic, and the narrations of Abd al-A'la from Ibn al-Hanafiyyah are da'if (weak) according to the people of hadith. And Allah knows best.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الخلع والطلاق / 15143