#abc116b. [abc116_b]Collatz Problem
[abc116_b]Collatz Problem
Problem Statement
A sequence is determined as follows:
-
The first term is given as input.
-
Let be the following function: if is even, and if is odd.
-
when , and when .
Find the minimum integer that satisfies the following condition:
- There exists an integer such that .
Constraints
- All values in input are integers.
- It is guaranteed that all elements in and the minimum that satisfies the condition are at most .
Input
Input is given from Standard Input in the following format:
Output
Print the minimum integer that satisfies the condition.
Sample Input 1
8
Sample Output 1
5
. As , the answer is .
Sample Input 2
7
Sample Output 2
18
$a=\\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\\}$.
Sample Input 3
54
Sample Output 3
114