FR 5712 then IB 651 at Madrid
Budapest → Madrid → Rome
Timetable, Madrid time
19:00FR 5712 from Budapest at the gate
13:05IB 651 to Rome leaves the gate
18 h 05 apart on the timetable, overnight
IB 651 leaves 18 h 05 after FR 5712 arrives on the timetable: more than half a day, so not a connection we count.