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

Solution (Python):
a = int(input())
l = [a,a]
n = 1
end = 0
tmp = 0
while end == 0:
    if l[n] % 2 == 0:
        tmp = int(l[n]/2)
    else:
        tmp = int(l[n]*3 + 1)
    n = n + 1
    if tmp in (l):
        end = 1
    l.append(tmp)

print(n)

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

s = int(input())
aPrev = s
isFound = [False] * 10**6
isFound[aPrev] = True
for m in range(2, 10**6 + 1):
    a = f(aPrev)
    if isFound[a]:
        print(m)
        break
    aPrev = a
    isFound[a] = True

Solution (Python):
s = int(input())
flag = [0] * 1000001
flag[s] = 1
for i in range(1, 1000001):
    if s % 2:
        s = 3 * s + 1
    else:
        s = s // 2
    if flag[s]:
        print(i+1)
        break
    flag[s] = 1

Solution (Python):
s=int(input())
l=[]
b=s
i=0
while b not in l:
  l.append(b)
  a=l[-1]
  if a%2==0:
    b=a//2
  else:
    b=a*3+1
  
  i+=1
print(i+1)

Solution (Python):
s = int(input())
a = []
a.append(s)
n = 0
while True:
	if a[n]%2 == 0:
		an = a[n]/2
	else:
		an = 3*a[n] + 1
	if an in a:
		print(n+2)
		exit()
	else:
		a.append(an)
	n += 1

Solution (Python):
s = int(input())
a = set([s])
x = s
ans = 1
while len(a) == ans:
  if x%2 == 0:
    x = int(x/2)
    a.add(x)
    ans += 1
  else:
    x = 3*x+1
    a.add(x)
    ans += 1
print(ans)

Solution (Python):
s = int(input())
A = [s]

for i in A:
    if(i%2==0):
        A.append(int(i/2))
        inde = (int(i/ 2))
    else:
        A.append(int(3*i + 1))
        inde = int(3 * i) + 1
    if(inde in A[:-1]):
        print(len(A))
        break

Solution (Python):
s = int(input())
ss = set()
ss.add(s)
k = 1
while True:
    if s%2 == 0:
        s = s/2
    else:
        s = 3*s + 1
    s = int(s)
    if s in ss:

        break
    ss.add(s)

    k+=1

print(k+1)

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

x = {}
i = 1
x[s] = i
while True:
  i += 1
  k = f(s)
  if k in x:
    print(i)
    break
  x[k] = i
  s = k

Solution (Python):
s = int(input())
nums = []
nums.append(s)
while True:
  if s%2==0:
    s = s/2
  else:
    s = 3*s+1

  if s in nums:
    print(len(nums)+1)
    exit()
  else:
    nums.append(s)

Solution (Python):
s = int(input())
def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3*n + 1
flag = [0 for i in range(1000001)]
flag[s] = 1
a = [s]

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

Solution (Python):
s = int(input())
def f(s):
    return s/ 2 if s % 2 == 0 else 3 * s + 1
a = [s]
while len(a) > 0:
    if f(s) in a:
        print(len(a)+1)
        break
    else:
        s = f(s)
        a.append(s)

Solution (Python):
s=int(input())

a=[s]
k=0
ans=2
while k==0:
    if a[-1]%2==0:
        p=a[-1]//2
    else:
        p=3*a[-1]+1
    for i in a:
        if i==p:
            print(ans)
            k=1
            break
    a.append(p)
    ans+=1

Solution (Python):
s = int(input())
a = [0]*1000010

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

Solution (Python):
s = int(input())
S = [s]

N = 1000000
for i in range(N):
	if s%2 == 0:
		s = s//2

		

		if s in S:
			ans = i+2
			break
		S.append(s)
	else:
		s = 3*s+1

		

		if s in S:
			ans = i+2
			break
		S.append(s)

print(ans)

Solution (Python):
s = int(input())
k = set()
k.add(s)
a = [s]
a1 = s
i = 2
while True:
    if a[-1] % 2 == 0:
        
        a.append(a[-1]//2)

    else:
        
        a.append(3*a[-1] + 1)

    if a[-1] in k:
        print(i)
        exit()
    else:
        k.add(a[-1])
        i += 1

Solution (Python):
s = int(input())
lines = [s]
for line in lines:
  if(line%2 == 0):
    even = int(line / 2)
    if(even not in lines):
      lines.append(even)
    else:
      break
  else:
    odd = 3*line + 1
    if(odd not in lines):
      lines.append(odd)
    else:
      break
print(lines.index(lines[-1])+2)

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


def main():
    series = [int(input())]
    for i in range(1000000):
        s = f(series[-1])
        if s in series:
            print(i + 2)
            return
        else:
            series.append(s)


main()

Solution (Python):
import numpy as np

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

Solution (Python):
def main():
    S = int(input())
    a = [S]
    i = 0
    while True:
        i += 1
        if a[i - 1] % 2 == 0:
            a_ = a[i - 1] / 2
        else:
            a_ = 3 * a[i - 1] + 1
        if a_ in a:
            print(i + 1)
            return
        a.append(a_)


if __name__ == "__main__":
    main()

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

s = int(input())

array = []

while s not in array:
	array.append(s)
	s = f(s)

print(len(array)+1)

Solution (Python):
S = int(input())

a = set([])

a1 = S
i = 0
while not(a1 in a):
    a.add(a1)
    i = i + 1
    if (a1 % 2 == 0):
        a1 = int(a1 / 2)
    else:
        a1 = a1 * 3 + 1

print(i+1)

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

Solution (Python):
s=int(input())
dic={}
dic[s]=dic.get(s,0)+1
i=1
while True:
	if s%2==0:
		s=s//2
	else:
		s=3*s+1
	dic[s]=dic.get(s,0)+1
	if dic[s]>=2:
		print(i+1)
		exit(0)
	i+=1

Solution (Python):
s = int(input())
a = [s]
for i in range(1, 11000):
    if a[i - 1] % 2 == 0:
        tmp = a[i - 1] // 2

        if a.count(tmp) == 1:
            print(i + 1)
            break
        else:
            a.append(tmp)
    else:
        tmp = 3 * a[i - 1] + 1

        if a.count(tmp) == 1:
            print(i + 1)
            break
        else:
            a.append(tmp)

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

Solution (Python):


N = int(input())  




cnt = 0
if N == 1:
    print(4)
elif N ==2:
    print(4)
else:
    while N !=1:
        if N%2==0:
            N = N//2
        else:
            N =3*N+1
        cnt += 1
    print(cnt+2)

Solution (Python):
init = int(input())
numbers = []
counter = 1
a = init
while a not in numbers:
    numbers.append(a)
    if a % 2 == 0:
        a = a // 2
    else:
        a = 3*a + 1
    counter += 1
print(counter)

Solution (Python):
s = int(input())

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

a =[]

a.append(s)
while(True):
  am=func(a[-1])
  if am in a:
    print(len(a)+1)
    break
  else:
    a.append(am)

Solution (Python):
s = int(input())
def f(n):
    if n %2 == 0:
        return int(n / 2)
    else:
        return int(3*n+1)
ans = 0
a = []
a.append(s)
i = 1
while True:
    
    ai = f(a[i-1])
    if ai in a:
        ans = i
        break
    a.append(ai)
    i+=1

print(ans +1 )

Solution (Python):
import numpy
def func(s):
	if s % 2 == 0:
		return int(s/2)
	else:
		return 3*s + 1
s = int(input())
check = numpy.zeros(1000010)
check[s] = 1
Ind = 1
while True:
	s = func(s)
	Ind += 1
	if check[s] == 1:
		print(Ind)
		exit()
	else:
		check[s] = 1

Solution (Python):
s = int(input())
def f(n):
  if n%2:
    return 3*n+1
  else:
    return n/2
L = []
for m in range(1000000):
  if sum(x == s for x in L):
    print(m+1)
    break
  else:
    L.append(s)
    s = f(s)

Solution (Python):
s = int(input())

seta = set()
seta.add(s)

p = s
c = s
i = 2
while True:
    if p%2 == 0:
        c = p//2
    else:
        c = 3*p+1

    if c in seta:
        break
    else:
        seta.add(c)

    p = c
    i += 1

print(i)

Solution (Python):
s = int(input())

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

print(cnt + 3)

Solution (Python):


import numpy
import scipy

from collections import defaultdict
from pprint import pprint

a1 = int(input())

x = a1
cnt = 1
a = {a1: 1}
while True:
    cnt += 1
    if x % 2 == 0:
        x = int(x / 2)
    else:
        x = 3 * x + 1
    if x in a:
        break
    else:
        a[x] = 1
print(cnt)

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

s =int(input())
l =[]
i =1
while not s in l:
    l.append(s)
    s =f(s)
    i+=1
print(i)

Solution (Python):
s = int(input())
count = 1
if s == 4 or s == 2 or s == 1:
    print(4)
    exit()

while s != 4:
    if s % 2 == 0:
        s = s//2
    else:
        s = s*3+1
    count += 1
print(count + 3)

Solution (Python):

"""
Created on Sun Jan 20 21:02:12 2019

@author: owner
"""

s=int(input())
dic={}
ans=0

dic[s]=1
for i in range(2,1000001):
    if s%2==0:
        s//=2
    else:
        s=3*s+1
    if dic.get(s,0)>0:
        ans=i
        break
    else:
        dic[s]=1
print(ans)

Solution (Python):
c=int(input())
s=[c]
for i in range(100000):
    if c%2!=1:
        c=c//2
    else:
        c=3*c+1
    if not c in s:
        s.append(c)
    else:
        print(i+2)
        break

Solution (Python):
s = int(input())
now = s
old = []
count = 1
while now not in old:
	count += 1
	if now % 2 == 0:
		old.append(now)
		now = now //2
	else:
		old.append(now)
		now = 3*now + 1
print(count)

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

Solution (Python):
s = int(input())

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

numlist = [s]
for i in range(1000000):
    if i+1 == 1:
        x = s
    else:
        x = x
    x = f(x)
    if numlist.count(x) == 1:
        print(i+2)
        break
    else:
        numlist.append(x)

Solution (Python):
s = int(input())

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

se = set()
se.add(s)

i = 2
a = s
while True:
    a = f(a)
    if a in se:
        print(i)
        break
    se.add(a)
    i += 1

Solution (Python):
s= int(input())
num_list = []

def function_tmp(n):
    if n % 2 == 0:
        return n/2
    else:
        return 3*n +1
tmp = s
cnt = 1
while not(tmp in num_list):
    num_list.append(tmp)
    tmp = function_tmp(tmp)
    
    cnt += 1
print(cnt)

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

s = int(input())
lst = [s]
n = 2
while True:
    tmp = f(lst[-1])
    if tmp in lst:
        print(n)
        break
    lst.append(tmp)
    n += 1

Solution (Python):

s = int(input())

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


l = []
l.append(s)

for i in range(10000000000):
	
	a = f_n(l[-1])

	if a in l:
		print(i + 2)
		break
	else:
		l.append(f_n(l[-1]))

Solution (Python):
s=int(input())
a=[s]
tmp=s
index=1
while True:
    if tmp%2==0:
        tmp=tmp/2
        a.append(int(tmp))
        index+=1
    else:
        tmp=tmp*3+1
        a.append(int(tmp))
        index+=1

    if len(a)!=len(list(set(a))):
        print(index)
        exit(0)

Solution (Python):
def fun(n):
    if n%2:return 3*n+1
    return n//2
a=[0]+[int(input())]
i=1
while not fun(a[i]) in a:a.append(fun(a[i]));i+=1
print(i+1)

Solution (Python):
def f(n):
    if n & 1:
        return 3 * n + 1
    else:
        return n//2

p = int(input())
t = {p}
m = 1
while True:
    m += 1
    p = f(p)
    if p in t:
        break
    t.add(p)
print(m)

Solution (Python):
s = int(input())

res = s
i = 1


while True:
    if s == 1:
        print(4)
        break
    if s == 2:
        print(4)
        break
    if res == 1:
        print(i+1)
        break
    if res % 2 == 0:
        res = res // 2
        i = i+1
    else:
        res = res * 3 + 1
        i = i+1

Solution (Python):
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)

Solution (Python):
a = int(input())
s = set()
for i in range(1,1000002):
  if a in s:
    print(i)
    exit()
  s.add(a)
  if a%2==0:
    a=a//2
  else:
    a=a*3+1

Solution (Python):
s=int(input())

L=[s]
N=s
for i in range(10000000):
    if N%2==0:
        if N//2 in L:
            print(i+2)
            
            break
        else:
            L.append(N//2)
            N=N//2
    else:
        if 3*N+1 in L:
            print(i+2)
            
            break
        else:
            L.append(3*N+1)
            N=3*N+1

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

s = int(input())
m = s
q = set([s])
r = 1
while True:
  r += 1
  if f(m) in q:
    print(r)
    break
  else:
    q.add(f(m))
    m = f(m)

Solution (Python):
s = int(input())

li = [s]
n = 2
while 1:
    if s%2:
        s = s*3+1
    else:
        s //= 2

    if s in li:
        print(n)
        exit()
    else:
        li.append(s)
        n+=1

Solution (Python):
s = int(input())

a = s

a_list = [a]

while True:
    if a %2 == 0:
        a = a/2
    else:
        a = 3*a + 1
        
    if a in a_list:
        break
    
    a_list += [a]

print(len(a_list) + 1)

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

Solution (Python):
s = int(input())
array = [s]
for i in range(1, 100000):
    if array[i-1] % 2 == 0:
        tmp = array[i-1]//2
        if tmp in array:
            print(i+1)
            exit()
        array.append(tmp)
    else:
        tmp = 3*array[i-1] + 1
        if tmp in array:
            print(i+1)
            exit()
        array.append(tmp)

Solution (Python):
s = int(input())

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

a=[]
a.append(s)
for m in range(2,1000001):
    x = f(a[m-2])
    if x in a:
        ans = m
        break
    else:
        a.append(x)

print(ans)

Solution (Python):

s = int(input())
d = {s:1}
before = s
i = 1

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

while True:
    i += 1
    ai = f(before)
    if ai in d:
        res = i
        break
    else:
        d[ai] = i
        before = ai


print(res)

Solution (Python):
s=int(input())
l=[4,2,1]
cnt=1
while s not in l:
    if s%2==0:
        s=s//2
        cnt+=1
    else:
        s=s*3+1
        cnt+=1
print(cnt+3)

Solution (Python):

def inpl(): return list(map(int, input().split()))
s = int(input())

searched = [0]*(10**6+1)

def func(x):
    if x%2 == 0:
        return x//2
    else:
        return 3*x + 1
searched[s] = 1
for i in range(2, 10**6+2):
    s = func(s)
    if searched[s]:
        print(i)
        break
    else:
        searched[s] = i

Solution (Python):
s=int(input())
a={s}
i=1
an_1=s
def f(num):
    if num%2==0:
        return num//2
    else:
        return num*3+1
while True:
    i+=1
    an=f(an_1)
    if an in a:
        print(i)
        break
    else:
        a.add(an)
        an_1=an

Solution (Python):


import sys


INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n = II()

u = set([n])
cnt = 2
while True:
    if n % 2:
        n = 3 * n + 1
    else:
        n //= 2
    if n in u:
        print(cnt)
        exit()
    u.add(n)
    cnt += 1

Solution (Python):
s = int(input())
a = set()
a.add(s)

for i in range(2, 1000010):
	if s % 2 == 0:
		s = s//2
	else:
		s = 3*s+1
	if s in a:
		print(i)
		break
	a.add(s)

Solution (Python):
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

x = ip()                              








a = []
a.append(x)
num =1
while True:
    num+=1
    if x%2:
        x = (3*x)+1
    else: x//=2
    if x in a:
        print(num)
        exit(0)
    a.append(x)

Solution (Python):
s = int(input())
def an(n):
    if n == 1:
        return s
    else:
        return f(an(n-1))

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

se = set()
n = 1
while True:
    a = an(n)
    
    if a in se:
        print(n)
        exit()
    se.add(a)
    n += 1

Solution (Python):
S = int(input())


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


collatz_list = []
collatz_set = set()
num = S
ans = 1
while True:
    if num in collatz_set:
        break
    else:
        collatz_list.append(num)
        collatz_set.add(num)
        num = collatz(num)
        ans += 1
print(ans)

Solution (Python):
s = int(input())
a = set([s])
for i in range(2, 1000000):
  if s % 2 == 0:
    t = s // 2
  else:
    t = 3 * s + 1
  if t in a:
    print(i)
    exit()
  a.add(t)
  s = t

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

s = int(input())
i = 1
seta = set([s])
while True:
    s = f(s)
    if s in seta:
        break
    seta.add(s)
    i += 1
print(i + 1)

Solution (Python):
s = int(input())

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

Solution (Python):
s = int(input())

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

ans=2
while f(s) not in l:
    s=f(s)
    l.append(s)
    ans+=1


print(ans)

Solution (Python):
s = int(input())
tmp = [False] * 1000001
i = 1
a = s
tmp[a] = True
while True:
    if a % 2 == 0:
        a //= 2
        i += 1
        if tmp[a]:
            print(i)
            exit()
        tmp[a] = True
    else:
        a = 3*a + 1
        i += 1
        if tmp[a]:
            print(i)
            exit()
        tmp[a] = True

Solution (Python):
s=int(input())
l=[]
l.append(s)
for i in range(10**7):
  if s%2==0:
    s=int(s/2)
  else:
    s=3*s+1
  if s in l:
    break
  else:
    l.append(s)
print(i+2)

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

Solution (Python):
s=int(input())

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

ai=s
i=1
a=[s]


while True:
	if f(ai) in a:
		print(i+1)
		break
	else:
		a.append(f(ai))
		ai=f(ai)
		i+=1

Solution (Python):
s = int(input())
f = lambda n: n//2 if n%2 == 0 else 3*n+1
a = set([s])
for m in range(2, 10**6+1):
    s = f(s)
    if s in a:
        print(m)
        break
    a.add(s)

Solution (Python):
s = int(input())

def f(n):
    if n % 2 == 0:
        return int(n / 2)

    else:
        return int(3*n + 1)

x = []

x.append(s)
y = 1
while True:
    y += 1
    s = f(s)
    if s in x:
        print(y)
        exit()
    x.append(s)

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


s = int(input())
i = 2
a = s
b = f(s)
d = {s: 1}
while b not in d:
    d[b] = 1
    a = b
    b = f(b)
    i += 1
print(i)

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

Solution (Python):
s = int(input())
a = [s]
cnt = 2

while True:
    if a[-1]%2 == 1:
        if a[-1]*3+1 in a:
            print(cnt)
            exit()
        else:
            a.append(a[-1]*3+1)
            cnt += 1
    else:
        if a[-1]//2 in a:
            print(cnt)
            exit()
        else:
            a.append(a[-1]//2)
            cnt += 1

Solution (Python):
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
s=I()
sl=[s]
i=1
while True:
    t=s
    if s%2==0:
        s=t//2
    else:
        s=3*t+1
    
    if s in sl:
        print(len(sl)+1)
        break
    else:
        sl.append(s)

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

s = int(input())
lst = [s]
for i in range(1, 1000001):
    x = f(lst[-1])
    if x in lst:
        break
    lst.append(x)
print(i+1)

Solution (Python):
s = int(input())

a = [s]

for i in range(1, 1000001):
    now = 0
    if a[i-1] % 2 == 0:
        a.append(a[i-1] // 2)
        now = a[i-1] // 2

    else:
        a.append(a[i-1] * 3 + 1)
        now = a[i-1] * 3 + 1


    
    if now in a[:i]:
        print(i+1)
        break

Solution (Python):
s = int(input())

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

S = {s}
for i in range(10 ** 6):
    s = f(s)
    if s in S:
        print(i + 2)
        break
    else:
        S.add(s)

Solution (Python):
from sys import stdin
s = set()
cur = 1
a = int(stdin.readline())
while True:
  if a in s:
    break
  s.add(a)
  cur = cur+1
  if a%2==0:
    a= a/2
  else:
    a = 3*a+1
print cur

Solution (Python):
from collections import defaultdict
H = defaultdict(lambda: 0)
s = int(input())
ctr = 1
while True:
    if H[s]:
        break
    H[s] = ctr
    ctr += 1
    s = (s//2, 3*s+1)[s%2]
print(ctr)

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

Solution (Python):
s = int(input())
X = set()
X.add(s)


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


for ans in range(2, 10 ** 6 + 1):
    am = f(s)
    if am in X:
        print(ans)
        break
    else:
        s = am
        X.add(am)

Solution (Python):
s = int(input())

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

i = 1
pre = set()
pre.add(s)
while i < 10 ** 6 + 1:
    tmp = f(s)
    if tmp in pre:
        print(i + 1)
        exit()
    i += 1
    s = tmp
    pre.add(tmp)

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

Solution (Python):
S = int(input())


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

print(i)

Solution (Python):
n = int(input())
l = []
i = 1
while(1):
    if n in l:
        print(i)
        exit()
    l.append(n)
    i+=1
    if n%2==0:
        n = int(n/2)
    else:
        n = 3*n + 1

Solution (Python):
import collections
import math
import re
import numpy
def ai():return input()
def a():return int(input())
def ma():return map(int, input().split())
def ms():return map(str, input().split())
def lma():return list(map(int, input().split()))
def lms():return list(map(str, input().split()))
def say(i):return print("Yes" if i == 0 else "No")
def Say(i):return print("YES" if i == 0 else "NO")
k= [0]
l = []
f = 0
s=0
c=0
e =1
k[0] =a()
for i in range(0,1000001):
    if k[i] in k[:i]:
        c=i
        break
    if k[i]%2==0:
        k.append(k[i]//2)
    else:k.append(k[i]*3+1)
print(c+1)

Solution (Python):
s = int(input())


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

A = [s]

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

Solution (Python):
s=int(input())
NOW=set()
A=s
for i in range(10**7):
    if A in NOW:
        break
    
    if A%2==0:
        NOW.add(A)
        A=A//2
    else:
        NOW.add(A)
        A=3*A+1

print(i+1)

Solution (Python):
s = int(input())

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

a = [s]
m = 1
while True:
    m += 1
    t = f(a[-1])
    if t in a:
        print(m)
        exit()
    else:
        a.append(t)

Solution (Python):
def solve(s):
    d = set()

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

    while True:
        d.add(s)
        s = f(s)
        if s in d:
            return len(d) + 1


if __name__ == "__main__":
    s = int(input())
    print(solve(s))

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

Solution (Python):
def f(n):
  return n//2 if not n%2 else 3*n+1

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

while 1:
  v=f(l[-1])
  if v in l:
    print(len(l)+1)
    break
  l.append(v)

Solution (Python):
n = int(input())
lis = [0 for i in range(10000000)]
cou = 1
while 1:
    if lis[n] == 1:
        print(cou)
        exit()
    lis[n] = 1
    if n % 2 == 0:
        n = n // 2
    else:
        n = 3 * n +1
    cou += 1

Solution (Python):
s = int(input())
seen = {s}
steps = 2

while True:
  if s & 1:
    s = 3 * s + 1
  else:
    s >>= 1
  if s in seen:
    print(steps)
    break
  steps += 1
  seen.add(s)

Solution (Python):
from collections import defaultdict
def collatz(a):
    if a % 2 == 0:
        return a//2
    return 3*a+1

s = int( input())
d = defaultdict( int)
d[s] = 1
for i in range(2, 1000000):
    s = collatz(s)
    if d[s] == 0:
        d[s] = 1
    else:
        ans = i
        break
print( ans)

Solution (Python):
s = int(input())
def f(n):
    if n%2 == 0:
        return n/2
    else:
        return 3*n + 1
a = []
ans = 1
while s not in a:
    a.append(s)
    s = f(s)
    ans += 1
print(ans)

Solution (Python):
s = int(input())
b = s
a=[]
t = True
i = 0
while t:
    if b in a:
        print(i+1)
        exit()
    else:
        a.append(b)
        if b%2 == 0:
            b = b//2
        else:
            b = 3*b + 1
        i += 1

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

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

Solution (Python):
s=input()
A=[s]
Ans=1

while True:
    Ans+=1
    if A[-1]%2==0:
        a=A[-1]/2
    else:
        a=A[-1]*3+1
    if a in A:
        break
    else:
        A.append(a)
        
print Ans

Solution (Python):
s = input()
S = set()
S.add(s)
m = 1
while True:
  s = s/2 if s%2==0 else 3*s+1
  m += 1
  if s in S:
    print m
    break
  S.add(s)

Solution (Python):
INF, MOD = float("inf"), 1e9 + 7
MAX, MIN = -INF, INF
dx1, dy1, dx2, dy2 = [-1, 0, 1, 0], [0, -1, 0, 1], [-1, 0, 1, -1, 1, -1, 0, 1], [-1, -1, -1, 0, 0, 1, 1, 1]

def get_int():
    return int(input())

def get_int_list():
    return list(map(int, input().split()))

def mins(x, y):
    x = min(x, y)

def maxs(x, y):
    x = max(x, y)

while(True):
    try:
        n = int(input())
        a = []
        a.append(n)
        while(True):
            x = 3 * a[len(a) - 1] + 1 if a[len(a) - 1] % 2 else int(a[len(a) - 1] / 2)
            if x in a:
                print(len(a) + 1)
                break
            a.append(x)
    except EOFError:
        exit()

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

Solution (Python):

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def LIR(n): return [LI() for i in range(n)]
mod = 1000000007


"""
a,b,c = LI()
s = a+b+c
s /= 2
ans = (s*(s-a)*(s-b)*(s-c))**(1/2)
print(int(ans))
"""


s = int(input())
m = 1
lis = [True for i in range(1000001)]

while lis[s]:
    lis[s] = False
    if s % 2 == 1:
        s = 3*s+1
    else:
        s //= 2
    m += 1
print(m)

Solution (Python):
d = {}
s = int(input())
d[s] = 1
i = 1
while 1:
    if s & 1:
        s = 3*s+1
    else:
        s = s//2
    i += 1
    if s in d:
        print(i)
        break
    d[s] = i

Solution (Python):
n = int(input())
cnt = 1

bl = [False] * (10**6 + 1)
bl[n] = True

while 1:
    cnt += 1
    if n % 2 == 0:
        next = n // 2
    else:
        next = 3 * n + 1
    if bl[next]:
        break
    n = next
    bl[n] = 1

print(cnt)

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

i = 0
n = int(input())
while True:
    if n == 4 or n == 2 or n == 1:
        print(i+4)
        break
    i += 1
    n = f(n)