Problem:


Score : 200 points

Problem Statement

A sequence a=\{a_1,a_2,a_3,......\} is determined as follows:

The first term s is given as input.

Let f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd.

a_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1.

Find the minimum integer m that satisfies the following condition:

There exists an integer n such that a_m = a_n (m > n).

Constraints

1 \leq s \leq 100

All values in input are integers.

It is guaranteed that all elements in a and the minimum m that satisfies the condition are at most 1000000.

Input

Input is given from Standard Input in the following format:

s

Output

Print the minimum integer m that satisfies the condition.

Sample Input 1

8

Sample Output 1

5

a=\{8,4,2,1,4,2,1,4,2,1,......\}. As a_5=a_2, the answer is 5.

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



Sample input:
8


Sample output:
5

Submission status: Runtime Error

Solution code:
s = int(input())

def calc_next(x):
  if x % 2 == 0:
    return x // 2
  else:
    return 3 * x + 1

a = [s]
n = 1

while True:
  a.append(calc_next(a[n-1]))
  for i in range(n):
    if a[k] == a[n]:
      print(n+1)
      exit(0)
  n += 1

Submission status: Runtime Error

Solution code:
s = int(input())
l=[s]
i=1
def func(a):
  if a%2==0:
    return(a/2)
  else:
    return(3*a+1)

def Collatz(s):
  i+=1
  l.append(func(s))
  if not len(l) == len(set(l)):
    print(i)
    break
  else:
    continue

Collatz(s)

Submission status: Runtime Error

Solution code:
s = map(int, input().split())
l=[s]
i=1
def func(a):
  if a%2==0:
    return(a/2)
  else:
    return(3*a+1)

def Collatz(s):
  i+=1
  l.append(func(s))
  if not len(l) == len(set(l)):
    print(i)
    break
  else:
    continue

Collatz(s)

Submission status: Runtime Error

Solution code:
s = map(int, input().split())
l=[s]
i=1
def func(a):
  if a%2==0:
    return a/2
  else:
    return 3s+1

def Collatz(s):
    i+=1
	l.append(func(s))
	if not len(l) == len(set(l)):
        print(i)
        break
    else:
        continue
Collatz(s)

Submission status: Runtime Error

Solution code:
s = map(int, input().split()
l=[s]
i=1
def func(a):
  if a%2==0:
    return a/2
  else:
    return 3s+1

def Collatz(s):
    i+=1
	l.append(func(s))
	if not len(l) == len(set(l)):
        print(i)
        break
    else:
        continue

Submission status: Runtime Error

Solution code:
a, b, _ = map(int, input().split())
print(a * b / 2)

Submission status: Runtime Error

Solution code:
s = int(input())
f = [s]
i = 1
n = s
while(i<=1000001):
  if n % 2 == 0:
    f.append(int(n/2))
  else:
    f.append(3*n+1)
  n = f[i]
  i = i + 1
f_ = list(dict.fromkeys(f))
f.pop(f.index(f_[0]))
print(f.index(f_[0]))

Submission status: Runtime Error

Solution code:
def f(a):
    if a // 2 == 0:
        return a // 2
    if a // 2 == 1:
        return 3 * a + 1

s = int(input())
a = [s]
done = False
while not done:
    for i in range(len(a)):
        if a[i] != f(a[-1]):
            a.append(f(a[-1]))

        else:
            print(i)
            done = True
            break

Submission status: Runtime Error

Solution code:
s=int(input())
a=[s]
i=1
while len(a)==len(set(a)):
  if a[i-1]%2=0:
    a.append(a[i-1]//2)
  else:
    a.append(a[i-1]*3+1)
  i+=1
print(i)

Submission status: Runtime Error

Solution code:
s = int(input())
f = []
i = 0
n = s
while(i<1000000):
  if n % 2 == 0:
    f.append(n/2)
  else:
    f.append(3*n+1)
  n = f[i]
  i = i + 1
f_ = list(dict.fromkeys(f))
f.pop(f.index(f_[0]))
print(f.index(f_[0])+1)

Submission status: Runtime Error

Solution code:
s = int(input())
ans = 1
nums = set()
while s not in nums:
  ans += 1
  if s % 2 == 0: s // = 2
  else: s = s * 3 + 1
  nums.add(s)
print(ans)