W6 2391 then FR 5356 at Madrid
Budapest → Madrid → Krakow
Timetable, Madrid time
08:55W6 2391 from Budapest at the gate
06:00FR 5356 to Krakow leaves the gate
21 h 05 apart on the timetable, overnight
FR 5356 leaves 21 h 05 after W6 2391 arrives on the timetable: more than half a day, so not a connection we count.