9344 - The 3n+1 Problem   

Description

Consider the following algorithm:
step 1. Input n
step 2. Set Count to be 0
step 3. If n is equal to 1, then STOP
Else Set
step 4. Count = Count +1
step 5. GOTO Step 3.
Given one integer n. Please output the count after processing the algorithm.

For example:
If n = 22, then according to the algorithm. You will get 22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1. Thus the count for 22 is 15.

Input

The input contains several test cases and will end with EOF. In each test case, there is only one line contains an integer n.
Case1: 1<=n<=1500
Case2: 1<=n<=9000
Case3: 1<=n<=100000
Case4: 1<=n<=1000000
[Hint]
For Case1, the value during operation will not exceed 10^6.
For Case2, the value during operation will not exceed 10^7.
For Case3, the value during operation will not exceed 2^31.
For Case4, the value during operation will not exceed 2^63.
For Case3~4, you may need to store the count of n that has already been calculated.

Output

For each test case, output the count of n.

Sample Input  Download

Sample Output  Download

Tags




Discuss