Scanf.scanf "%d" (fun i ->
    let rec loop i r =
        if r = 4 then i + 3 else
            if r mod 2 = 0 then loop (i + 1) (r / 2)
                           else loop (i + 1) (r * 3 + 1)
    in
    Printf.printf "%d\n" @@ if i = 1 || i = 2 then 4 else loop 1 i
)