Snakes and Ladders Is Code Correct? - Graph

CODE

My answer is coming it to be 3, whereas in the course the answer comes out as 4. Kindly point out the error.