If I understand the question correctly then two stopovers in London, one at each end of the itinerary is no problem - I sometimes do Ex-CAI AONE3s that way (with a LHR-IST-LHR-CAI mileage run at the end). But obviously you can't also stopover in MAD since that would be 3 stopovers in the continent of origin.