12) C

To go from X to Y, it takes 2 hours 30 minutes (2.5 hours). Then it stays for 1 hour. So we can say that the trip from X to Y takes 3 hours 30 minutes. (3.5 hrs)

From the timetable, we see that ferries set sail from each port every 1.5 hours.

Let us use an example to solve this question.

From port X, a ferry (let us call this ferry 1) leaves at 00:00. It will arrive at Y at 02:30. It will stay till 03:30. Then arrive back at X, 2 hours 30 minutes later at 06:00.

We know that from port X, ferries leave at the following times between 00:00 and 06:00: 01:30, 03:00, 04:30 and then 06:00.
At 00:00, ferry 1 departs.
At 01:30, ferry 2 would depart.
At 03:00, ferry 3 would depart.
At 04:30, ferry 4 would depart.
At 06:00, ferry 5 would depart.

Ferry 1 arrives back at X at 06:00 however, it cannot depart immediately as it has to stay for 1 hour.
Therefore, this timetable requires 5 ferries in total.