#K66087. Minimum Operations to Transform to One

    ID: 32342 Type: Default 1000ms 256MiB

Minimum Operations to Transform to One

Minimum Operations to Transform to One

You are given an integer n. Your task is to determine the minimum number of operations required to reduce n to 1 using the following rules:

  • If n is even, replace n with n/2.
  • If n is odd, replace n with 3n+1.

This process is based on the famous Collatz Conjecture. Formally, the operations can be described as:

$$ n = \begin{cases} \frac{n}{2} & \text{if } n \equiv 0 \; (\bmod\;2), \\ 3n + 1 & \text{if } n \equiv 1 \; (\bmod\;2). \end{cases} $$

Determine and output the number of operations needed to transform n into 1.

inputFormat

The input consists of a single integer n (where n ≥ 1), provided via standard input.

outputFormat

Output a single integer, which is the minimum number of operations required to transform n into 1.

## sample
6
8