FR 6712 then FR 5323 at Madrid
Budapest → Madrid → Milan Bergamo
Timetable, Madrid time
11:55FR 6712 from Budapest at the gate
11:05FR 5323 to Milan Bergamo leaves the gate
23 h 10 apart on the timetable, overnight
FR 5323 leaves 23 h 10 after FR 6712 arrives on the timetable: more than half a day, so not a connection we count.