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):
s = int(input())
visited = set()
count = 0

while True:
    count += 1
    if s in visited:
        break
    else:
        visited.add(s)
        if s%2 == 0:
            s = s//2
        else:
            s = 3*s+1

print(count)

Solution (Python):
s = int(input())
dict = {s:1}
while(1):
    if s % 2 == 0:
        s = s // 2
    else:
        s = 3 * s + 1
    if s in dict:
        break
    else:
        dict[s] = 1
print(len(dict)+1)

Solution (Python):
s = int(input())
if s == 1 or s == 2:
    print(4)
    exit(0)
cnt = 1
while(1):
    cnt += 1
    
    if s == 1:
        break
    elif s % 2 == 0:
        s = s // 2
    else:
        s = 3 * s + 1
print(cnt)

Solution (Python):
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
s, = [int(num) for num in lines.pop(0).split(" ")]
count = 2
ss = set([s])
while True:
    if s % 2 == 0:
        next = s // 2
    else:
        next = 3 * s + 1
    if next in ss:
        break
    else:
        ss.add(next)
        s = next
        count += 1
print(count)

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

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

l = [0]*1000001
check = [False]*5000000

l[1] = s
ans = 0

for i in range(2, 1000000):
    if l[i-1] % 2 == 0:
        l[i] = round(l[i-1]/2)
    else:
        l[i] = 3*l[i-1]+1

for i in range(1,1000000):
    if check[l[i]]==False:
        check[l[i]]=True
    else:
        ans=i
        break

print(ans)

Solution (Python):
import numpy as np
s = int(input())

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

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

Solution (Python):
n = int(input())
a = [n]
cnt = 1
while True:
    if a[-1] % 2 == 0:
        x = [a[-1] // 2]
        if set(x) & set(a) == set():
            a.append(x[0])
        else:
            cnt += 1
            break
    else:
        x = [a[-1] * 3 + 1]
        if set(x) & set(a) == set():
            a.append(x[0])
        else:
            cnt += 1
            break
    cnt += 1
print(cnt)

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

a = [0]
a.append(int(input()))
for i in range(2,1000001):
    tmp = f(a[i-1])
    if tmp in a:
        break
    a.append(tmp)

print(i)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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


def main():
    s = int(readline())

    d = dict()

    a = s
    d[a] = 1
    for i in range(2, 10000000):
        a = f(a)
        if a in d:
            ans = i
            break
        else:
            d[a] = i

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
s=int(input())
A=[s]
while s!=1:
    if s%2==0:
        s=s//2
        A.append(s)
    else:
        s=(3*s)+1
        A.append(s)
AA=A+[4,2,1]
if AA[0]==1 or AA[0]==2:
    print(4)
else:
    for m in range(len(AA)):
        for n in range(len(AA)):
            if AA[m]==AA[n] and m>n:
                M=m-1
                break
    print(M)

Solution (Python):
from collections import defaultdict

s = int(input())
D = defaultdict(int)
D[s] += 1
ans = 1

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

while True:
  s = f(s)
  ans += 1
  if D[s] == 1:
    print(ans)
    break
  D[s] += 1

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

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

a=[s]
for i in range(10000000):
    a_last = f(a[i])
    if a_last in a:
        print(i+2)
        break
    a.append(a_last)

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

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

v = [False] * 1000001
v[s] = True

i = 1
while True:
    i += 1
    if s % 2 == 0:
        s = s // 2
    else:
        s = 3 * s + 1
    
    if v[s]:
        break
    else:
        v[s] = True

print(i)

Solution (Python):
s=int(input())
def f(x):
  if x%2==0:
    return x//2
  else:
    return 3*x+1
alist=[s]
for i in range(2,1000001):
  s=f(s)
  if s in alist:
    print(i)
    break
  else:
    alist.append(s)

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



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

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

s = int(input())
c = 1
n = s
l = [s]

while True:
  m = calc(n)
  if l.count(m) == 1:
    break
  l.append(m)
  c += 1
  n = m
   
print(c+1)

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

A = []
A.append(s)

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

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

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

Solution (Python):
s = int(input())
cnt = 0
if s!=1 and s!=2:
  cnt = 0
  while s != 4:
    if s % 2 == 0:
      s = s / 2
    else:
      s = 3 * s + 1
    cnt += 1
print(cnt+4)

Solution (Python):
s=int(input())
if s==1 or s==2:
  print(4)
else:
  i=1
  while s!=1:
    i+=1
    if s%2==0:
      s/=2
    else:
      s=s*3+1
  print(i+1)

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

Solution (Python):
def collatz(n):
	c = 1
	check = [n]
	while(True):
		c += 1
		if n & 1 == 0:
			n = n // 2
			if n in check:
				break
			check.append(n)
		else:
			n = (n * 3) + 1
			if n in check:
				break
			check.append(n)
	return c
n = int(input())
print(collatz(n))

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

Solution (Python):
n=int(input())
from collections import defaultdict
d=defaultdict(int)
def find(n,i):
    if d[n]!=0:
        return i
    d[n]=i
    if n%2==0:
        return find(n//2,i+1)
    else:
        return find(3*n +1 ,i+1)

print(find(n,1))

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

f = [s]

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

Solution (Python):








n = int(input())


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

a = [n]
for i in range(2, 1000001):
    n = func(n)
    if n in a:
        print(i)
        exit()
    else:
        a.append(n)

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

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

a = s
ar = [a]
for i in range(1, 100000000):
    if(a % 2 == 0):
        a = a/2
    else:
        a = 3*a + 1
    if(ar.count(a) == 1):
        
        print(i+1)
        break
    
    ar.append(a)

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

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

Solution (Python):
s=int(input())
ss=[s]
n=s
for i in range(2,10**6):
  if n%2==0:
    n=n/2
    if n in ss:
        print(i)
        quit()
    ss.append(n)
  else:
    n=3*n+1
    if n in ss:
        print(i)
        quit()
    ss.append(n)

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

a = s
for i in range(2, 10**6):
    if a % 2 == 0:
        if a // 2 in l:
            print(i)
            exit()
        l.append(a // 2)
        a = a // 2
    else:
        if 3 * a + 1 in l:
            print(i)
            exit()
        l.append(3 * a + 1)
        a = 3 * a + 1

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

A = []

while a not in A:
    A.append(a)
    if a%2 == 0:
        a = a//2
    else:
        a = 3*a + 1

print(len(A) + 1)

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

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

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

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

a = [s]
i = 1
while True:
    s = f(s)
    i += 1
    if s in a:
        break
    a += [s]
print(i)

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

Solution (Python):
s = int(input())
T = set()
T.add(s)
for i in range(1000001):
  if s%2:
    s = s*3 + 1
  else:
    s = s // 2
  l = len(T)
  T.add(s)
  if l == len(T):
    print(i+2)
    exit()

Solution (Python):
if __name__ == '__main__':

	n = int(input())
	A = []
	cnt = 1
	A.append(n)

	while True:
		if n % 2 == 0:
			n = n // 2
		else:
			n = 3 * n + 1
		cnt += 1
		if n in A:
			print(cnt)
			break
		A.append(n)

Solution (Python):
import math


def resolve():
    import sys
    input = sys.stdin.readline
    
    
    s = int(input().rstrip())
    opened = set()
    opened.add(s)
    prev = s
    m = 1
    while True:
        m += 1
        y = int(prev / 2) if prev % 2 == 0 else (3 * prev + 1)
        if y in opened:
            print(m)
            break
        prev = y
        opened.add(y)









if __name__ == "__main__":
    resolve()

Solution (Python):
a=[0]*10**7
a[1]=int(input())
cnt=[a[1]]

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

for i in range(2,10**7+1):
  a[i] = f(a[i-1])
  if a[i] in cnt:
    print(i)
    break
  else:
    cnt.append(a[i])

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

A = [int(input())]
i = 1
while True:
  x = collatz(A[-1])
  if x in A:
    print(i + 1)
    break
  else:
    A.append(x)
    i += 1

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

Solution (Python):
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    s=ii()
    X = [s]
    seen = set([s])
    for i in range(10**6+10):
        x = X[-1]
        if x % 2 == 0:
            y = x//2
        else:
            y = 3*x+1
        
        X.append(y)
        if y in seen:
            print(i+2)
            
            exit()

        seen.add(y)
    
    assert False




        





if __name__ == "__main__":
    main()

Solution (Python):
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    s = ni()
    d = {}
    d[s] = 1
    ans = 1
    while True:
        ans += 1
        if s % 2 == 0:
            s = s // 2
        else:
            s = 3 * s + 1
        if s in d:
            print(ans)
            return
        else:
            d[s] = 1


if __name__ == '__main__':
    main()

Solution (Python):
def collatz(n):
    return 3*n+1 if n%2 else n//2
a,n=[],int(input())
while len(set(a))==len(a):
    a.append(n)
    n=collatz(n)
print(len(a))

Solution (Python):
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = inint()

a = [s]
al = [s]


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

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

Solution (Python):
s=int(input())
def collatz(number):            
    if number % 2 == 0:          
        number /= 2              
    else:                        
        number = 3 * number + 1  
    return int(number)
c=0
while s!=1 and s!=2 and s!=4:
    s=collatz(s)
    c=c+1
else:
    print(c+4)

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

Solution (Python):
s=int(input())
def f(x):
    if x%2==0:
        return x//2
    else:
        return 3*x+1
a=s
ans=[s]
for i in range(10**6+5):
    a=f(a)
    if a in ans:
        print(i+2)
        exit()
    ans.append(a)

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

s=int(input())
cnt=1
while s!=4 and s!=2 and s!=1:
  cnt+=1
  s=f(s)
print(cnt+3)

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

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

Solution (Python):
s = int(input())
a = s
A = []
A.append(s)
count = 0

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

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

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

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

Solution (Python):
n=int(input());a=[]
while n not in a: a.append(n);n=[3*n+1,n//2][n%2==0]
print(len(a)+1)

Solution (Python):
n=int(input());a=[]
while n not in a:
  a.append(n);n=[3*n+1,n//2][n%2==0]
print(len(a)+1)

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

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

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

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

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

    n.append(s)

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

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

a = [s]
last = s

while True:
    if last % 2 == 0:
        last //= 2
    else:
        last = last * 3 + 1

        
    if last in a:
        print(len(a) + 1)
        exit()
    else:
        a.append(last)

Solution (Python):
import sys
from collections import defaultdict


def input():
    return sys.stdin.readline().rstrip()


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

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

    ss = set()
    ss.add(s)

    for i in range(10 ** 8):
        s = f(s)
        if s in ss:
            print(i+2)
            exit()
        ss.add(s)



if __name__ == "__main__":
    main()

Solution (Python):
s = int(input())
an = [s]
for i in range(1, 1000000):
    if an[i-1]%2==0:
        ins = an[i-1]//2
    else:
        ins = 3*an[i-1]+1

    if ins not in an:
        an.append(ins)
    else:
        print(i+1)
        exit()

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

answer_list = []
answer_list.append(s)
count = 1
while True:
    count += 1
    next_s = 0
    if s % 2 == 0:
        next_s = s // 2
    else:
        next_s = s * 3 + 1
    s = next_s
    if s in answer_list:
        print(count)
        exit()
    answer_list.append(s)

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

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

a = {s}
b = s 
for i in range(2,1000001):
    if b%2==0:
        b //= 2
    else:
        b = 3*b+1

    if b in a:
        print(i)
        exit()
    else:
        a.add(b)

Solution (Python):
def main():
    s = int(input())
    i = 1
    l = [s]
    flag = 0
    while flag == 0:
        if s % 2 == 0:
            s = s // 2
        else:
            s = 3*s + 1
        i += 1
        if s in l:
            print(i)
            return
        else:
            l.append(s)
main()

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

s = int(input())
old = s
count=1
history={s}
while 1:
  new = f(old)
  count += 1
  if new in history:
    break
  history.add(new)
  old = new

print(count)

Solution (Python):
def collatz(num):
    if num % 2 == 0:
        return num // 2
    elif num % 2 == 1:
        return num * 3 + 1

n = int(input())
collatz_list = [n]

for i in range(10**6):
    n = collatz(n)
    if not n in collatz_list:
        collatz_list.append(n)
    else:
        print(i+2)
        break

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

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

for i in range(1,1000001):
  if i == 1:
    a.append(s)
  elif s%2 == 0:
    s = s/2
    if s in a:
      print(i)
      exit()
    else:
      a.append(int(s))
  elif s%2 == 1:
    s = 3*s+1
    if s in a:
      print(i)
      exit()
    else:
      a.append(int(s))

Solution (Python):
s=int(input())
li=[s]
for i in range(10**6):
    if s%2==1:
        s=3*s+1
        li+=[s]
    else:
        s//=2
        li+=[s]
    if len(li)!=len(set(li)):
        print(i+2)
        break

Solution (Python):
s = int(input())
an = [s]
for i in range(1, 1000000):
    if an[i-1]%2==0:
        ins = an[i-1]//2
    else:
        ins = 3*an[i-1]+1

    if ins not in an:
        an.append(ins)
    else:
        print(i+1)
        exit()

Solution (Python):
























































global FLAG_LOG
FLAG_LOG = False


def log(value):
    
    
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    
    s = int(lines[0])
    
    
    
    

    values = [s]

    for i in range(1000000):
        s = func_f(values[i])
        if s in values:
            return [i+2]
        values.append(s)


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



def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['8']
        lines_export = [5]
    if pattern == 2:
        lines_input = ['7']
        lines_export = [18]
    if pattern == 3:
        lines_input = ['54']
        lines_export = [114]
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    if FLAG_LOG:
        log(f'lines_input=[{lines_input}]')
        log(f'lines_export=[{lines_export}]')
        log(f'lines_result=[{lines_result}]')
        if lines_result == lines_export:
            log('OK')
        else:
            log('NG')
    finished = time.time()
    duration = finished - started
    log(f'duration=[{duration}]')



if __name__ == '__main__':
    main()

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

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

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

seq = [s]

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

m = 1
while True:
  i = m-1
  a = f(seq[i])
  
  if a in seq:
    break
  seq.append(a)
  m += 1
print(m+1)

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

for _ in range(1,1000):
    if s % 2 != 0:
        a.append(int(3*s+1))
        s = int(3*s+1)
    else:
        a.append(int(s/2))
        s = int(s/2)

cnt = 0
ans = []

for i,j in zip(a,a[1:]):
    ans.append(i)
    if j in ans:
        ans.append(j)
        print(len(ans))
        break

Solution (Python):
S=int(input())
flag = True
n = 2
List=[S]
res = 0
while flag:
  if S % 2 == 0:
    S = S // 2
  else:
    S = 3* S +1
  if List.count(S) ==0:
    List.append(S)
  else:
    res = n
    flag = False
  n += 1
print(res)

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

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

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

Solution (Python):


s = int(input())

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

print(ans)

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

ans = [s]
idx = 1
tmp = s
while True:
    if tmp % 2 == 0:
        tmp = tmp//2
    else:
        tmp = (3*tmp) + 1
    idx +=1

    if tmp in ans:
        print(idx)
        exit()
    else:
        ans.append(tmp)

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

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

ans = [s]
count = 2
while (n:=f(ans[-1])) not in ans:
    ans.append(n)
    count += 1

print(count)

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

s = int(input())

A = [s]
i = 0
while A[i] not in A[:i]:
  A.append(func(A[i]))
  i += 1
print(i + 1)

Solution (Python):
s = int(input())
l = []
l.append(s)
i = 1
ans = 2

while True:
    if l[i-1]%2 == 0:
        a = int(0.5*l[i-1])
    else:
        a = 3*l[i-1] +1

    if a in l:
        ans = i + 1
        break
    else:
        i += 1
        l.append(a)
        continue
print(ans)

Solution (Python):
n = int(input())
check = 0
keep = []

def q(n, check):
    if n in keep:
        return check
    else:
        keep.append(n)
    if n % 2 == 0:
        n = n // 2
    else:
        n = 3 * n + 1
    return q(n, check+1)
print(q(n,check)+1)

Solution (Python):
s = int(input())
x = []
x.append(s)
m = 1
z = 0
if s % 2 == 0:
    y = s // 2
else:
    y = 3 * s + 1
m += 1
x.append(y)
while z == 0:
    n = y
    if  n % 2 == 0:
        y = n // 2
    else:
        y = 3 * n + 1
    if y in x:
        z += 1
        m += 1
        print(m)
    else:
        m += 1
        x.append(y)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]

from collections import defaultdict 



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

x = ii()
d = defaultdict(int)
d[x] = 1
ind = 1
while True:
    ind += 1
    if d[f(x)] == 1:
        print(ind)
        exit()
    d[f(x)] += 1
    x = f(x)

Solution (Python):
l = [int(input())]

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

Solution (Python):
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    a = int(input())
    exist = [0] * (10**6 + 1)
    exist[a] = 1
    ans = 1
    while(True):
        ans += 1
        if a%2 == 0: 
            a //= 2
        else: 
            a = 3*a + 1
        if exist[a] == 1: 
            print(ans)
            return
        else: 
            exist[a] = 1
        
if __name__ == '__main__':
    main()

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

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

s = int(input())
a = [s]
B = True
i = 0
while B:
  a.append(f(a[i]))
  if a.count(f(a[i])) > 1:
    print(i+2)
    break
  i += 1

Solution (Python):
import numpy as np
s = int(input())
a = np.full(1000001,-1)
a[0] = s
for i in range(1,1000001):
    if a[i-1] % 2 == 0:
        a[i] = a[i-1] // 2
    elif a[i-1] % 2 != 0:
        a[i] = 3*a[i-1] + 1
    
    if a[i] in set(a[:i-1]):
        print(i+1)
        break

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

print(i+1)

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


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

A = [s]
while True:
  a = f(A[-1])
  if a in A:
    ans = len(A) + 1
    break
  else:
    A.append(a)


print(ans)

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

a = [s]

ans = 1
while(True):
  ans += 1
  if a[-1]%2 == 0:
    num = a[-1]//2
  else:
    num = a[-1]*3+1
  for i in range(len(a)):
    if a[i] ==num:
      print(ans)
      sys.exit()

  a.append(num)

Solution (Python):
import sys
s=int(input())
dp=[0]*1000001
dp[s]=1
cnt=1
for i in range(1000001):
  if s%2==1:
    s=3*s+1
  else:
    s//=2
  cnt+=1
  if dp[s]==1:
    print(cnt)
    sys.exit()
  else:
    dp[s]=1

Solution (Python):
s=int(input())
x=[]
for i in range(1000000):
  if len(list(set(x)))!=len(x):
    print(len(x))
    break
  elif s%2==0:
  	x.append(s)
  	s=int(s/2)
  else:
  	x.append(s)
  	s=3*s+1

Solution (Python):
import math
def main():
  s = int(input())
  numarray=[s]
  ans=0
  i=1
  while True:
    if s%2==1:
      s=3*s+1
    else:
      s=int(s/2)
    if s in numarray:
      break
    else:
      numarray.append(s)
      i+=1
  print(i+1)
main()

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

for i in range(10**5):
    if S_lst[i] % 2 == 0:
        S_lst.append(S_lst[i] / 2)
    else:
        S_lst.append(3 * S_lst[i] + 1)
    if S_lst[i+1] in S_lst[:-1]:
        print(i+2)
        break

Solution (Python):
def f(x):
    if x%2:
        return 3*x + 1
    else:
        return x/2
s = int(input())
a = [s]
for i in range(1,10**6+2):
    if f(a[i-1]) in a:
        print(i+1)
        break
    a.append(f(a[i-1]))

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

s = int(input())

log = set([s])

cnt = 1

while True:
    if fnc(s) in log:
        cnt += 1
        print(cnt)
        break
    else:
        s = fnc(s)
        log.add(s)
        cnt += 1

Solution (Python):
import sys
from collections import defaultdict

sys.setrecursionlimit(10**7)
input = sys.stdin.readline

s = int(input())
dic = defaultdict(int)
dic[s] += 1
cnt = 1
while True:
    if s % 2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    cnt += 1
    dic[s] += 1
    if dic[s] > 1:
        print(cnt)
        exit()

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

for n in range(1000000):
  if a[n]%2==0:
    if int(a[n]/2) not in a:
      a.append(int(a[n]/2))
    else:
      print(n+2)
      exit()
  else:
    if int(3*a[n]+1) not in a:
      a.append(int(3*a[n]+1))
    else:
      print(n+2)
      exit()

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

s = int(input())
ans = 1

while s != 4 and s != 2 and s != 1:
    s = judge(s)
    ans += 1

print(ans+3)