A3 877 then A3 4034 at Athens
Budapest → Athens → Madrid
Timetable, Athens time
17:05A3 877 from Budapest at the gate
17:00A3 4034 to Madrid leaves the gate
23 h 55 apart on the timetable, overnight
A3 4034 leaves 23 h 55 after A3 877 arrives on the timetable: more than half a day, so not a connection we count.