#P6206. [USACO06OCT] Another Cow Number Game G

[USACO06OCT] Another Cow Number Game G

Problem Description

The cows are playing a number game, and Bessie wants you to help her predict the result. At the start of the game, Bessie is given a positive integer NN. Her score is 00 at this time.

The cows transform NN using the following rules:

  • If NN is odd, multiply it by 33 and then add 11.
  • If NN is even, divide it by 22.

Each time the number is transformed, Bessie gains 11 point. When N=1N=1, the game ends. The score at this time is her final score.

Input Format

One line containing one integer NN.

Output Format

One line containing one integer, which is Bessie’s final score.

5
5

Hint

Constraints

For 100%100\% of the testdata, 1N1061\le N\le 10^6.


Sample Explanation

When the initial value of NN is 55, the game proceeds as follows:

NN Number after the transformation Transformation Total score
55 1616 3×5+13\times 5+1 11
1616 88 16÷216\div 2 22
88 44 8÷28\div 2 33
44 22 4÷24\div 2 44
22 11 2÷22\div 2 55

Bessie’s final score is 55.

Translated by ChatGPT 5