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-----
8

-----Sample Output-----
5

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

Difficulty: introductory

Starter code:

Solutions:
from collections import defaultdict

d = defaultdict(bool)

n = int(input())
for i in range(1000000):

    if d[n]:
        print((i + 1))
        return
    d[n] = True
    if n & 1:
        n = n * 3 + 1
    else:
        n >>= 1


a=int(input())
b=[]
b.append(a)
while True:
    if a%2==0:
        a=a/2
        if a in b:
            print(len(b)+1)
            break
        else:
            b.append(a)
    elif a%2!=0:
        a=3*a+1
        if a in b:
            print(len(b)+1)
            break
        else:
            b.append(a)

s = int(input())
a = s
c = 0
if a == 1 or a == 2:
  ans = 4
else:
  while a != 1:
    if a%2 == 0:
      a = int(a/2)
      c += 1
    else:
      a = int(3*a+1)
      c += 1
  ans = c+2
print(ans)

s = int(input())
ans = [0]*1000001
cnt = 1

while True:
    if ans[s] == 0:
        ans[s] += 1

        if s%2 == 0:
            s = s//2
        else:
            s = 3*s+1
        cnt += 1

    if ans[s] != 0:
        print(cnt)
        return




s = int(input())

a = [0,s]
for n in range(2,10**6+1):
  if a[n-1] % 2 == 0:
    an = a[n-1] // 2
  else:
    an = a[n-1] * 3 + 1
  
  if an in a:
    m = n
    break
  
  a.append(an)
  
print(m)

a = int(input())
 
x = set()
x.add(a)

i = 1
while True:
  i += 1
    
  if a % 2 == 0: a //= 2
  else: a = 3*a + 1
  
  if a in x: break
  x.add(a)

print(i)

n=int(input())
li = []
while not n in li:
  li.append(n)
  if n % 2 == 0:
    n //= 2
  else:
    n = n * 3 + 1
  
print(len(li)+1)

s = int(input())

lst = [s]
prev = s
for m in range(2, 1000001):
    if prev % 2 == 0:
        i = int(prev / 2)
    else:
        i = 3 * prev + 1
    if i in lst:
        print(m)
        break
    lst.append(i)
    prev = i

s = int(input())
a = [s]
while True:
  if a.count(a[-1]) == 2:
    print(len(a))
    return
  if a[-1]%2 == 0:
    a.append(a[-1]/2)
  else:
    a.append(3*a[-1]+1)

n = int(input())
c = 0
x = []
while True:
    c+=1
    if n in x:
        print(c)
        break
    x.append(n)
    if n%2 == 0:
        n = n//2
    else:
        n = 3*n+1

n=int(input())
a=[n]
cnt=1
while len(set(a))==len(a):
    if n%2==0: 
        n//=2
    else:
        n=3*n+1
    a.append(n)
    cnt+=1
print(cnt)


s=int(input())
a=[0]*10**6
a[0]=s

def f(x):
  if x%2==0:
    return x//2
  else:
    return 3*x+1
t=0 
while f(a[t])>0:
  p=f(a[t])
  if p in a:
    print((t+2))
    return
  a[t+1]=p
  t+=1


def func(n: int) -> int:
    return n // 2 if n % 2 == 0 else n * 3 + 1


def answer(s: int) -> int:
    sequence_a = [s]
    while True:
        num = func(sequence_a[-1])
        if num in sequence_a:
            return len(sequence_a) + 1
        sequence_a.append(num)


def main():
    s = int(input())
    print((answer(s)))


def __starting_point():
    main()

__starting_point()

import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return list(map(int,input().split()))
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
num = []
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

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

s = k()
num.append(s)
while True:
    cnt += 1
    s = f(s)
    if s in num:
        print((cnt+1))
        return
    else:
        num.append(s)
        




s = int(input())
TMP = [s]

if s==1 or s==2:
    print(4)
else:
    while TMP[-1]!=1:
        if TMP[-1] % 2 == 0:
            TMP.append(TMP[-1]//2)
        elif TMP[-1] % 2 != 0:
            TMP.append(3 * TMP[-1] + 1)
    print(len(TMP)+1)

s = int(input())
l = []
def myfunc(x):
  if x%2 == 0:
    x = x//2
  else:
    x = 3*x + 1
  return x
for i in range(10**6):
  l.append(s)
  s = myfunc(s)
  if s in l:
    print(i+2)
    break

s = int(input())
a = [s]
i = 0
while True:
    i = i+1
    # 前回の値によって計算を変える。
    if a[i-1] % 2 == 0:
        n = a[i-1]//2
    else:
        n = 3*a[i-1]+1
    # 数列に同じ値が含まれているかどうか？
    if n in a:
	  	# 配列が0から始まるため、カウントアップ。
        print((i+1))
        break
    a.append(n)


s=int(input())
col=[]
a=s
count=1
while True:
  col.append(a) 
  if a%2==0:
    a=a/2
  else:
    a=a*3+1
  if a in col:
    print(count+1)
    break
  count+=1

s=int(input())
def calc(n):
  if n % 2 == 0:
    return n / 2
  else:
    return 3*n +1
ans = []
ans.append(s)
for i in range(1000001):
  if calc(ans[i]) in ans:
    print(len(ans) +1)
    return
  else:
    ans.append(int(calc(ans[i])))

def main():
    def f(n):
        return 3 * n + 1 if n % 2 else n // 2
    s = int(input())
    a = [s]
    for i in range(1, 11**6):
        x = f(a[i-1])
        if x in a:
            return len(a) + 1; return
        a.append(x)


print(main())

s=int(input())
a=[]
ans=1
while True:
  a.append(s)
  if s%2==0:
    s//=2
  else:
    s=s*3+1
  ans+=1
  if s in a:
    print(ans)
    break

s = int(input())
li = []
li.append(s)

for i in range(1,1000000000):
    if li[i-1] % 2 == 0:
        li.append(li[i-1]//2)
    else:
        li.append(li[i-1]*3+1)

    for j in range(len(li)-1):
        if li[j] ==li[i]:
            print((i+1))
            return


s = int(input())
a = [s]
b = 1
while True:
    if s % 2 == 0:
        s = s // 2
    else:
        s = 3 * s + 1
    if s in a:
        print(len(a) + 1)
        return
    a.append(s)

s = int(input())
L = []
for c in range(2 , 10 ** 6 + 1):
  L.append(s)
  if s % 2 == 0:
    s = s // 2
  elif s % 2 == 1:
    s = s * 3 + 1
  if s in L:
    break
print(c)

s = int(input())

if s == 1 or s == 2:
    print(4)
    return

def function(n):
    if n % 2 == 0:
        return int(n/2)
    else:
        return int(n*3+1)
i = 0
count = 0
a = []
a.append(s)
while count < 2:
    a.append(function(a[i]))
    if a[i] == 4:
        count += 1
    i += 1
print(i)

n=int(input())
l=[n]
while True:
    if n%2==0:
        n//=2
    else:
        n=n*3+1
    if n in l:
        break
    else:
        l.append(n)
print((len(l)+1))


s = int(input())
list_a = [None]
list_a.append(s)
ans = 0
for i in range(1, 10 ** 6 + 1):
    if list_a[i] % 2 == 0:
        list_a.append(list_a[i] // 2)
    else:
        list_a.append(3 * list_a[i] + 1)
    if list_a[i] in list_a[:i]:
        ans = i
        break
print(ans)

s = int(input())
S = [str(s)]
i = 1
while True:
    if s % 2 == 0:
        i += 1
        s = s//2
        S.append(str(s))
        if S.count(str(s)) == 2:
            print(i)
            return
    else:
        i += 1
        s = int(3 * s + 1)
        S.append(str(s))
        if S.count(str(s)) == 2:
            print(i)
            return
pass


import sys
import copy
s = int(input())

def f(n):
    if n%2==0:
        return int(n/2)
    else:
        return 3*n+1

for i in range(1000000):
    if i == 0:
        a=[s]
    else:
        a.append(f(a[i-1]))
    
    if a.count(a[i]) == 2:
        print((i+1))
        return


# import math
# import statistics
a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#    c.append(i)
# e1,e2 = map(int,input().split())
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]

da=True
ap=[a]
count=1
while da:
    if a%2==0:
        a=a//2
        ap.append(a)
    elif a%2==1:
        a=3*a+1
        ap.append(a)
    count+=1
    if len(set(ap))<len(ap):
        print(count)
        da=False


a = int(input())
 
dic = {}
dic[a] = 1

i = 1
while True:
  i += 1
  if a % 2 == 0: a //= 2
  else: a = 3*a + 1
    
  if a in dic: break
  dic[a] = 1
  
print(i)

s = int(input())

if s < 3:
  print(4)
  return

cnt = 1
val = s
while True:
  if cnt > 1 and val == 1:
    break
  
  if val % 2 == 0:
    val = val//2
  else:
    val = val*3+1
    
  cnt += 1
             
print(cnt+1)

s=int(input())
def calc(n):
  if n % 2 == 0:
    return n / 2
  else:
    return 3*n +1
ans = [s]
for i in range(1000001):
  if calc(ans[i]) in ans:
    print(len(ans) +1)
    return
  else:
    ans.append(int(calc(ans[i])))

n = int(input())
a = [n]
index = 0

for i in range(1, 1000000):
    if a[i - 1] % 2 == 0:
        m = a[i - 1] / 2
    else:
        m = 3 * a[i - 1] + 1
    if m in a:
        index = i + 1
        break
    a.append(m)
print(index)

s = int(input())

max_ = 1000000
chk = [0]*max_
a = s
i = 1
while i <= max_:
    if chk[a] == 0:
        chk[a] += 1
    else:
        print(i)
        return
    if a%2 == 0:
        a = int(a/2)
    else:
        a = 3*a + 1
    i += 1


s = int(input())

A = [s]
idx = 1
while True:
    n = A[idx-1]
    if n % 2:
        f = 3*n + 1
    else:
        f = n / 2
    idx += 1
    A.append(f)
    if len(A) != len(set(A)):
        break
print(idx)

s = int(input())

count = 1
n = s
check = 0
list = [s]


for i in range(30000):
        if n % 2 == 0:
            n = n / 2
            list.append(n)
        else:
            n = n*3 + 1
            list.append(n)
        
        count = count + 1
        list.sort()
        for j in range(len(list) - 1):
            if list[j] ==list[j+1]:
                check = 1
                break
            
        if check == 1:
            break
        


print(count)



S = int(input())
s, c = S, 1
result = [s]
while True:
    if s % 2 == 0:
        s = s // 2
    elif s % 2 == 1:
        s = s * 3 + 1

    result.append(s)
    c += 1
    if len(set(result)) < len(result):
        break

print(c)

#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def func(n):
    ans =0
    if n%2==0:
        ans=n//2
    else:
        ans=3*n+1
    return ans

def main():
    s = int(input())
    dp=[s]
    counter=0

    if s==1 or s==2:
        print(4)
        return

    while counter < 1000001:
        n=dp.pop()
        tmp = func(n)
        dp.append(n)
        dp.append(tmp)
        counter+=1
        if tmp==4:
            print(dp.index(tmp)+4)
            break

def __starting_point():
    main()
__starting_point()

# -*- coding:utf-8 -*-
S = int(input())

a = [S]
cnt = 1
while True:
    if S%2 == 0:
        S /= 2
    else:
        S = 3*S + 1
    cnt += 1
    if S in a:
        break
    else:
        a.append(S)

print(cnt)

s = int(input())

num_lists = [s]
cnt = 1
while True:
    if (num_lists[-1])%2 == 0:
        tmp = num_lists[-1]/2
    else:
        tmp =(num_lists[-1]*3)+1
    cnt += 1
    if tmp in num_lists:
        ans = cnt
        break
    else:
        num_lists.append(tmp)

print(ans)

import sys
s=int(input())

cnt=0

if s==1 or s==2:
  print('4')
  return

while s!=4:
  if s%2!=0:
    s=3*s+1
    cnt+=1
  elif s%2==0:
    s=s//2
    cnt+=1

if s==4:
  print(cnt+4)

s=int(input())
a=[]
na=[]
a.append(s)
for i in range(1,10**6):
    if a[i-1]%2==0:
        a.append(a[i-1]/2)
    else:
        a.append(a[i-1]*3+1)
    na=set(a)
    if len(na)!=i+1:
        print(i+1)
        return

s = int(input())

a = []
a.append(s)
for i in range(1000000):
  if a[i]%2 == 0:
    a.append(a[i] // 2)
  else:
    a.append(3*a[i] + 1)
  for j in range(i-1):
    if a[i+1] == a[j]:
      print(len(a))
      return

s = int(input())
def p(n):
    if n%2 ==0:
        return n//2
    else:
        return 3*n+1
l = [s]
cnt = 1
while True:
    cnt +=1
    s = p(s)
    if s in l:
        print(cnt)
        return
    else:
        l.append(s)

s = int (input ())
l = []
a = 0
l.append (s)
for i in range (1000000):
  a += 1
  if s%2 == 0:
    s = round(s/2)
  else:
    s = s*3+1
  if l.count (s) != 0:
    print (a+1)
    break
  else:
    l.append (s)

s = int(input())


class Solution:
    def __init__(self,s):
        self.s = s
    
    def function_a(self):
        if self.s % 2 == 0:
            return self.s / 2
        else:
            return 3 * self.s + 1
    
    def answer(self):
        list_a = [self.s]
        self.s = self.function_a()
        ans = 2
        while self.s not in list_a:
            list_a.append(self.s)
            self.s = self.function_a()
            ans += 1
        print(ans)


conditon = Solution(s)
conditon.answer()

S = int(input())
l = []

while S not in l:
    l.append(S)
    if S%2 == 0:
        S //=2
    else:
        S = 3*S + 1
print((len(l)+1))


s = int(input())
S = {s}
i = 1
while True:
  i += 1
  if s % 2 == 0:
    s //= 2
  else:
    s = 3*s + 1
  if s in S:
    break
  S.add(s)
print(i)

s = int(input())

box = set()
box.add(s)

for i in range(2, 1000000):
  if s % 2 == 0:
    s //= 2
  else:
    s = s * 3 + 1
  if s in box:
    print(i)
    return
  else:
    box.add(s)


s = int(input())

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

coll = s
i = 1
while 1:
    if coll == 1 or coll == 2 or coll == 4:
        print(i  + 3)
        break
    coll = collatz(coll)
    i += 1

a = int(input())
 
x = set()
x.add(a)

i = 1
while True:
  i += 1
    
  if a % 2 == 0: a //= 2
  else: a = 3*a + 1
  
  if a in x: break
  x.add(a)
  
print(i)

S=int(input())

a=[S]
temp=S

i=0

while i<200:
	i+=1
	if temp%2==0:
		a.append(temp//2)
	else:
		a.append(temp*3+1)
	temp=a[-1]

for n in range(200):
	for m in range(n+1,200):
		if a[n]==a[m]:
			print(m+1)
			return

s=int(input())

a_list=[s]


a=s
while True:
    
    if a%2==0:
        a=a//2
    else:
        a=3*a+1
    
    if a in a_list:
        break
    else:
        a_list.append(a)

ans=len(a_list)+1

print(ans)

s = int(input())
a = [s]

def func(n):
  if n % 2 == 0:
    a.append(n//2)
  elif n % 2 == 1:
    a.append(3*n + 1)
  
i = 1
while True:
  func(a[-1])
  i += 1
  if a.count(a[-1]) == 2:
    break
  else:
    pass


print(i)

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


s = int(input())
cnt = 0
a = [s]
while True:

    temp = f(a[cnt])

    if temp in a:
        print((len(a)+1))
        return
    a.append(temp)
    cnt += 1


s = int(input())

def f(x):
    if x%2 == 0:
        return int(x/2)
    else:
        return 3*x + 1
i = 1
m_max = 1000000
b_s = s
b = set([s])
while i <= m_max:
    i += 1
    a = f(b_s)
    if a in b:
        break
    b.add(a)
    b_s = a
print(i)

s = int(input())
a = s
ans = 0

if (a == 1)or(a == 2)or(a == 4):
    ans = 4

else:

    for i in range(10**6 + 1):
        if a%2 == 0:
            a = int(a/2)
        else:
            a = 3*a + 1

        if a == 4:
            ans = i + 5
            break

print(ans)


s = int(input())
a = [s]
ans = 0
for i in range(1000000):
    if a[i] % 2 == 0:
        if a[i]/2 in a:
            ans = i + 2
            break
        a.append(a[i]/2)
    else:
        if 3*a[i] + 1 in a:
            ans = i + 2
            break
        a.append(3*a[i] + 1)
print(ans)

n = int(input())
c = 1
x = []
x.append(n)
while True:
    if n%2 == 0:
        n = n//2
    else:
        n = 3*n+1
    c+=1
    if n in x:
        break
    x.append(n)
print(c)

import sys
input = sys.stdin.readline


def main():
    S = int(input())

    x = set()
    x.add(S)

    i = 1
    prev = S
    while True:
        i += 1
        if prev % 2 == 0:
            prev = prev // 2
        else:
            prev = prev * 3 + 1

        if prev in x:
            print(i)
            return

        x.add(prev)




def __starting_point():
    main()


__starting_point()

s = int(input())
arr = []
ans = 0
def calc(n, cnt):
    arr.append(n)

    if cnt >= 1000000:
        return n

    if n % 2 == 0:
        n = int(n / 2)
    else:
        n = int(3 * n + 1)

    if n in arr:
        return cnt

    cnt += 1
    calc(n, cnt)
calc(s, 0)
print((len(arr) + 1))


def func(x):
  if x%2==0:
    return x//2
  else:
    return 3*x + 1
A = [True for i in range(1000001)]
N = int(input())
count = 1
while A[N]:
  A[N] = False
  N = func(N)
  count += 1
print(count)

a = [int(input())]

i = 0
while True:
    if a[i]%2 == 0:
        a.append(int(a[i]/2))
    else:
        a.append(int((3*a[i])+1))
    if a.count(a[i]) == 2:
        break
    i += 1

print(i+1)

s = int(input())
list_a = [s]

if s % 2 == 0:
    s = s / 2
else:
    s = 3 * s + 1
    
current = 2
while s not in list_a:
    list_a.append(s)
    if s % 2 == 0:
        s = s / 2
    else:
        s = 3 * s + 1
    current += 1

print(current)


s = int(input())

a = [0,s]
for n in range(2,10**6+1):
  if a[n-1] % 2 == 0:
    an = a[n-1] // 2
  else:
    an = a[n-1] * 3 + 1
  
  if an in a:
    m = n
    break
  
  a.append(an)
  
print(m)

s=int(input())

ans=1
s_st=set()
while s not in s_st:
  s_st.add(s)
  if s%2==0:
    s//=2
  else:
    s=3*s+1
  ans+=1

print(ans)

import sys
s = int(input())
f = [0 for _ in range(1000005)]
f[s] = 1
n = s
for i in range(1000005):
  if(n%2==0):
    n = int(n/2)
  else:
    n = int(3*n + 1)
  if(f[n] == 1):
    print(i+2)
    return
  else:
    f[n] = 1

s = int(input())

sec = [s]
count = 1
while(s):
  if sec[-1]%2 == 0:
    sec.append(sec[-1]/2)
  else:
    sec.append(3*sec[-1]+1)
  count+=1
    
  if sec[-1] in sec[:-1]:
    print(count)
    break

s = int(input())
line = [0 for i in range(1000001)]
ans = 1
line[s] += 1
while True:
  ans += 1
  if s % 2 == 0:
    s = int(s/2)
  else:
    s = 3*s + 1
  line[s] += 1
  if line[s] > 1:
    break
print(ans)

a = int(input())
l = [a]
for i in range(1000000):
  if a % 2 == 0:
    a = a//2
  else:
    a = a*3 + 1
  if l.count(a)==2:
    print((1+max([i for i, x in enumerate(l) if x == a])))
    break
  else:
    l.append(a)


s = int(input())
a = [s]
while True:
    if s % 2 == 0:
        s = s // 2
    else:
        s = s * 3 + 1
    a.append(s)
    if a.count(s) == 2:
        print(len(a))
        break

s = int(input())
a = [s]
i = 0
while True:
    i = i+1
    if a[i-1] % 2 == 0:
        n = a[i-1]//2
    else:
        n = 3*a[i-1]+1
    if n in a:
        print((i+1))
        break
    a.append(n)


s = int(input())
a = [s]
i = 1
while True:
  if s % 2 == 0:
    s = s // 2
  else:
    s = 3 * s + 1
  if s in a:
    print(len(a) + 1)
    break
  a.append(s)

s=int(input())
cnt = 1
S = [s]
while(1):
  cnt += 1
  if s % 2 == 0:
    s //= 2
  else:
    s = 3*s + 1
  if s in S:
    print(cnt)
    break
  S.append(s)


def readinput():
    s=int(input())
    return s

def main(s):
    hist=[0]*1000001
    i=1
    n=s
    hist[n]+=1
    while hist[n]<=1:
        if n%2==0:
            n=n//2
        else:
            n=3*n+1
        i+=1
        hist[n]+=1
    return i

def __starting_point():
    s=readinput()
    ans=main(s)
    print(ans)

__starting_point()

s = int(input())

mp = [False]*(10**6+1)
def even_f(n):
    return n//2

def odd_f(n):
    return 3*n+1

mp[s]=True
now = s
for i in range(1,10**6+1):
    if(now%2==0):
        now = even_f(now)
    else:
        now = odd_f(now)

    if(mp[now]):
        savei=i
        break
    mp[now]=True

print((savei+1))
        


s = int(input())
ans = [s]
i = 1
if s == 1 or s == 2:
    ans = 4
else:
    while ans[i-1] != 4:
        if ans[i-1] % 2 ==0:
            ans.append(ans[i-1]//2)
        else:
            ans.append(ans[i-1]*3 + 1 )
        i += 1
    ans = i + 3
print(ans)

import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')

s = I()
vs = set()
vs.add(s)
now = 0 + s
i = 1
while True:
    i += 1
    now = now / 2 if now % 2 == 0 else 3*now + 1
    if now in vs:
        break
    else:
        vs.add(now)

print(i)


s = int(input())
list_a = [s]

for i in range(1000000):
    if list_a[i] % 2 == 0:
        list_a.append(list_a[i] / 2)
    else:
        list_a.append(3 * list_a[i] + 1)
        
for index, ai in enumerate(list_a, 1):
    if ai in list_a[:index - 1]:
        print(index)
        break



url = "https://atcoder.jp//contests/abc116/tasks/abc116_b"

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


def main():
    s = int(input())
    ans = [s]
    while True:
        tmp = calc(ans[-1])
        ans.append(tmp)
        if ans.index(tmp) != len(ans)-1:
            print((len(ans)))
            break



def __starting_point():
    main()

__starting_point()

s=int(input())
L=[]
n=1
while not s in L:
  L.append(s)
  if s%2==0:
    s//=2
  else:
    s=s*3+1
  n+=1
print(n)

n = int(input())
data =[0]* 1000000
data[0] = n
i = 2
if n % 2 == 0:
    data[1] = n //2
else:
    data[1] = 3 * n + 1
while data[i - 1] not in data[0: i -2]:
    if data[i-1] % 2 == 0:
            data[i] = data[i - 1]//2
    else:
            data[i] = 3 * data[i - 1] + 1
    i += 1
print(i)

s=int(input())
G =[]
while (s not in G):
  G.append(s)
  if s % 2==0:
    s = int(s//2)
  else:
    s = int(3*s+1)
print(len(G)+1)

s = int(input())
l = [s]
a = set(l)
for i in range(10**6):
  if l[-1] % 2 == 0:
    n = l[-1] // 2
  else:
    n = 3*l[-1] + 1
  if n not in a:
    a.add(n)
    l.append(n)
  else:
    print(len(l)+1)
    break

a=int(input())
s=set()
i=1
while True:
    if a in s:
        print(i)
        break
    s|={a}
    if a%2==0:
        a>>=1
    else:
        a=3*a+1
    i+=1


s = int(input())

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

x = set()
ans = 0
while True:
    ans += 1
    if s in x:
        print(ans)
        break
    x.add(s)
    s = f(s)

a=int(input())
i=1
li=[a]
import copy
while True:
    if li[i-1]%2==0:
        b=li[i-1]//2
    else:
        b=3*li[i-1]+1
    if b in li:
        print((i+1))
        return
    li.append(b)
    i+=1
        


s=int(input())
def f(n):
    if n%2==0:
        return n//2
    else:
        return 3*n+1

a=[0]*(10**8)
a[s]=1
cnt=1
for _ in range(10**7):
    s=f(s)
    cnt+=1
    if a[s]:
        print(cnt)
        break
    a[s]=1


s = int(input())
a = s
ans = 0

if (a == 1)or(a == 2)or(a == 4):
    ans = 4

else:

    for i in range(10**6 + 1):
        if a%2 == 0:
            a = int(a/2)
        else:
            a = 3*a + 1

        if a == 4:
            ans = i + 5
            break

print(ans)


n = int(input())

dp = [True]*(n*1000000)
dp[n] = False
res =1
while n <1000001:
    res +=1
    if n % 2 ==1:
        n = n*3+1
    else:
        n = n//2
    
    if dp[n]:
        dp[n] = False
    else:
        print(res)
        return

s = int(input())

a = [0]*(10**6+1)
c = [0]*(10**6+1)
a[1] = s
c[s] = 1
for i in range(2, 10**6+1):
    v = a[i-1]//2 if a[i-1] % 2 == 0 else 3*a[i-1]+1
    a[i] = v
    if c[v] == 1:
        print(i)
        return
    c[v] = 1

S = int(input())
array = []
array.append(S)

while True:
  count = 0
  if S % 2 == 0:
    S = S / 2
    array.append(S)
  else:
    S = 3 * S + 1
    array.append(S)
  for i in range(len(array)):
    if S == array[i]:
      count += 1
      if count == 2:
        print((i + 1))
        return


a=int(input())
b=0
if a==2:
  print(4)
elif a==1:
  print(4)
else:
  while a!=4:
    if a%2==0:
      a=a//2
      b=b+1
    else:
      a=3*a+1
      b=b+1
  print(b+4)

s = int(input())

ans_list = [s]
curr_value = s
index = 1
while(True):
    if curr_value%2==0:
        curr_value = int(curr_value/2)
    else:
        curr_value = 3*curr_value + 1
    index += 1
    if curr_value in ans_list:
        break
    else:
        ans_list.append(curr_value)
print(index)

a = int(input())
s = set([a])

for i in range(10**6):
	if a % 2 == 0:
		# print("Process for even.")
		a = a//2
	else:
		# print("Process for odd.")
		a = 3*a + 1
	if a not in s:
		s.add(a)
	else:
		print((i+2))
		break


def f(n):
	if n % 2 == 0:
		return n / 2
	else:
		return 3 * n + 1
		
s = int(input())

a = []
for i in range(1000000):
	if i == 0:
		a.append(s)
	else:
		if f(a[-1]) in a:
			print(i+1)
			break
		else:
			a.append(f(a[-1]))

s = int(input())
visited = [False]*(10**6+1)

visited[s] = True
cnt = 1

while True:
    if s & 1:
        s = s * 3 + 1
    else:
        s //= 2
    
    cnt += 1

    if visited[s]:
        print(cnt)
        break

    visited[s] = True

s = int(input())
a = [s]
for i in range(1, 1000001):
    if a[i-1]%2 == 0:
        x = a[i-1]//2
        if x in a:
            print(i+1)
            break
        else:
            a.append(x)
    else:
        y = a[i-1]*3 + 1
        if y in a:
            print(i+1)
            break
        else:
            a.append(y)

from sys import stdin

s = int(stdin.readline().strip())
mem = []
a = s

for i in range(1000000):
  if a in mem:
    print(i+1)
    return
  mem.append(a)
  if a % 2 == 0: a = a // 2
  else: a = 3 * a + 1