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())
a = []
a.append(s)

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

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

Solution (Python):



s = int(input())

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

print(len(ls)+1)

Solution (Python):



s = int(input())

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

print(len(ls)+1)

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

l = []

while s not in l:
    l.append(s)

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

print(len(l)+1)

Solution (Python):
import sys



def loading_inputs():
    S = raw_input()
    S = int(S)
    return S


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


def check_index(li, x, i, default=-1):
    if x in li: return i + 1
    else:       return default



def main():

    ans = 0
    an  = list()

    a_i = loading_inputs()
    an.append(a_i)
    for i in range(1, 10**6):

        a_i = an_func(a_i)
        ans = check_index(an, a_i, i)
        if(ans!=-1):
            break
        else:
            an.append(a_i)

    print ans



if __name__ == "__main__":
    main()

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

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

Solution (Python):
s=int(input())
lis=[s]
loop=True
while loop:
    last=lis[-1]
    if last%2==0:
        val=int(last/2)
        if val in lis:
            loop=False
    else:
        val=int(3*last+1)
        if val in lis:
            loop=False
    lis.append(val)
print(len(lis))

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

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

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

Solution (Python):

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

Solution (Python):
s=int(input())
i=2
while~-s:s=[s//2,s*3+1][s%2];i+=1
print(max(i,4))

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


def collatz_problem(s: int) -> int:
    if s == 1 or s == 2 or s == 4:
        return 1 + 3

    i = 1
    while True:
        i += 1
        s = collatz(s)
        if s == 4:
            return i + 3

    return - 1


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

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

Solution (Python):
s = int(input())
m = 10**10
a = s
d = {}
d[a] = True
for i in range(2, 10**10):
    if a % 2 == 0:
        a = a // 2
    else:
        a = 3 * a + 1
    if a in d:
        break
    d[a] = True
print(i)

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

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

ans = 0

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

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

print(ans+1)

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

Solution (Python):
s = int(input())
a_list = [s]
INF = 10 ** 5
for i in range(INF):
    value = a_list[-1]
    if value % 2 == 0:
        next_value = value / 2
        if next_value in a_list:
            print(i + 2)
            break
        else:
            a_list.append(int(next_value))
    else:
        next_value = (3 * value) + 1
        if next_value in a_list:
            print(i + 2)
            break
        else:
            a_list.append(int(next_value))

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

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

print(cnt)

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

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

a = s
L = set()
i = 1
while not a in L:
    
    L.add(a)
    a = f(a)
    i+=1

print(i)

Solution (Python):
def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1 
s = int(input())
ans = 1
used = set()
while True:
    if s in used:
        break
    used.add(s)
    ans += 1
    s = f(s)
print(ans)

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


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

while len(set(s_list)) == len(s_list):
    s_list.append(f(s_list[-1]))

print(len(s_list))

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

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

    if nextNum in numList:
        print(ans)
        break
    numList.append(nextNum)
    count += 1
    ans += 1

Solution (Python):
def keisan(mylst, i):
    mylst.append(i)
    result = 0
    if i % 2 == 0:
        result = i/2
    else:
        result = 3*i+1

    if result in mylst:
        return len(mylst) + 1
    else:
        return keisan(mylst, result)

mylist = list()
s = int(input())
print(keisan(list(), s))

Solution (Python):
s, = (int(x) for x in input().split())

if s == 1 or s == 2 or s == 4:
    print("4")
    exit()

ncount = 1
while s != 1:
    ncount += 1
    if s%2 == 0:
        s = s//2
    else:
        s = 3*s+1

print(ncount+1)

Solution (Python):
from collections import Counter
s = int(input())

def func(n):
    if n % 2 == 0:
        return n // 2
    else :
        return 3 * n + 1
l = []
m = 0
l.append(s)
while True:
    l.append(func(l[m]))
    if 2 <= l.count(l[m+1]):
        print(m+2)
        break
    m += 1

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

l = [s]
count = 1
ans = 0
while(True):
    now = l[count-1]
    count += 1
    if (now % 2 == 0):
        next = now/2
    else:
        next = 3*now+1
    if next in l:
        ans = count
        break
    else:
        l.append(next)

print(ans)

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

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

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

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


s = int(input())

collatz = [s]
count = 1
continue_flg = True
while continue_flg:
    collatz_nums = set(collatz)
    count += 1
    s = f(s)
    for collatz_num in collatz_nums:
        if collatz_num == s:
            continue_flg = False
    collatz.append(s)
print(count)

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

s = set()
i = 1
a = int(input())
while True:
    if a in s:
        print(i)
        break

    s.add(a)
    a = f(a)
    i += 1

Solution (Python):
import sys
s = int(input())
a = [None]*2000000
r = [False]*2000000

def f(n):
  if n % 2 == 0:
    return n // 2
  else:
    return 3 * n + 1
a[1] = s
r[s] = True
for i in range(2, 2000000):
  a[i] = f(a[i-1])
  
  if r[a[i]]:
    print(i)
    sys.exit()
  r[a[i]] = True

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

chk=s
d={s:0}
for i in range(130):
    if chk%2: chk=chk*3+1
    else: chk//=2
    if chk in d:
        print(i+2)
        break
    else:
        d[chk]=0

Solution (Python):

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

def solve():
    s = int(input())
    l = []
    l.append(s)

    n = s
    count = 1
    while True:
        n = func(n)

        if n in l:
            print(count+1)
            return

        l.append(n)
        count += 1


if __name__ == "__main__":
    solve()

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

s = int(input())

num = [s]
count = 0
while True:
    
    ans = calc(num[count])
    if ans in num:
        print(count+2)
        break
    num.append(ans)
    count += 1

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

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

a=int(input())
L=[a]
b=1
while True:
  L.append(f(L[len(L)-1]))
  S=list(set(L))
  if len(L)==len(S):
    b+=1
  else:
    print(b+1)
    break

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

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

nums = set([s])
ans = 2
while True:
    s = s//2 if s%2 == 0 else 3*s+1
    if s in nums:
        print(ans)
        break
    else:
        nums.add(s)
        ans += 1

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

x = []
n = int(input())
x.append(n)
test = n

for i in range(1, 1000001):
    a = collatz(test)
    if a in x:
        print(i+1)
        exit()
    else:
        x.append(a)
        test = a

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

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

    return n

m = 10**6
num_li = []
num_li.append(s)
for i in range(m):
    if(function(num_li[i]) in num_li):
        print(i+2)
        break
    else:
        num_li.append(function(num_li[i]))

Solution (Python):
s = int(input())
A = list()
B = list()
A.append(s)
B.append(s)
i = 0
while len(A)==len(B):
  if A[i] % 2 == 0:
    A.append(A[i] // 2)
  else:
    A.append(3*A[i] + 1)
  B = set(A)
  i += 1
print(i+1)

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

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

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

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

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

aset = set([s])
preva = s
for m in range(10**6):
  if preva % 2 == 0:
    if preva // 2 in aset:
      break
    else:
      aset.add(preva // 2)
      preva = preva // 2
  else:
    if preva * 3 + 1 in aset:
      break
    else:
      aset.add(preva * 3 + 1)
      preva = preva * 3 + 1
print(m+2)

Solution (Python):
def even(n):
  return n//2
def odd(n):
  return 3*n+1
s=input()
if s in"124":
  print(4)
  exit()
s=int(s)
c=0
while 1:
  if s%2==0:
    s=even(s)
  else:
    s=odd(s)
  c+=1
  if s==4:
    print(c+4)
    exit()

Solution (Python):
from collections import defaultdict

s = int(input())
L = defaultdict(int)
m = 1
a = s
L[a] += 1
while True:
	m += 1
	if a % 2 == 0:
		a = int(a / 2)
	else:
		a = 3 * a + 1
	L[a] += 1
	if L[a] == 2:
		print(m)
		break

Solution (Python):
import sys
n = int(input())
if n==4:
    print(4)
    sys.exit()
elif n==2:
    print(4)
    sys.exit()
elif n==1:
    print(4)
    sys.exit()
a = n
b = 0
i = 1
while True:
    if a%2==0:
        b = a//2
    else:
        b = 3*a+1
    i+=1
    a = b
    
    if b ==4:
        break
print(i+3)

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

A = []

def a(i):
    if i == 1:
        return s
    elif A[i-2]%2:
        return 3*A[i-2]+1
    else:
        return A[i-2]/2

i = 1

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

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def collatz(n: int):
    if n%2:
        return 3*n+1
    else:
        return n//2
    
s = ni()
numset = set([s])

prev = s
cur = 0
idx = 1
for i in range(2 * 10**6):
    idx += 1
    
    cur = collatz(prev)
    prev = cur
    
    if cur in numset:
        break
    else:
        numset.add(cur)
        
print(idx)

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

Solution (Python):

import copy
import numpy as np
import random

s = int(input())


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

a = [s]
tmp = s
for i in range(1,10**6):
    tmp = func(tmp)
    if tmp in a:
        print(i+1)
        exit()
    else:
        a.append(tmp)

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

for i in range(10**8):
    ai1=f(a[i])
    if ai1 in a:
        print(i+2)
        break
    else:
        a.append(ai1)

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


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

a = []
c = []  
i = 1
a.append(s)
c.append(s)
while i <= 10000000:
  a.append(f(a[i-1]))
  if a[i] in c:
    print(i +1)
    break
  c.append(a[i])
  i += 1

Solution (Python):
def is_unique(seq):
    return len(seq)==len(set(seq))

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

Solution (Python):
s=int(input())
z=[s]
x=[]
for _ in range(100000):
    x.append(z[-1])
    if z[-1]%2==0:
        z.append(z[-1]//2)
    else:
        z.append(3*z[-1]+1)
    if z[-1] in x:
        print(len(z))
        break

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

print(i+1)

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

    for i in range(2, 1000000):
      x = int(a[-1] / 2) if a[-1] % 2 == 0 else int(a[-1] * 3 + 1)
      if x in a:
        print(i)
        break
      else:
        a.append(x)
    
    
if __name__ == '__main__':
    main()

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

while True:
	if a[-1] % 2 == 0:
		f = a[-1] / 2
	else:
		f = 3 * a[-1] + 1

	if f in a:
		break

	a.append(f)

print(len(a) + 1)

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

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

history = {}

a = s
for i in itertools.count(2):
    history[a] = True
    if a % 2:
        a = a * 3 + 1
    else:
        a = a // 2

    if history.get(a):
        print(i)
        break

Solution (Python):
s = int(input())
a={s}
tmp_a = s
index = 1
def func(n):
  if n%2==0:
    return n/2
  else:
    return 3*n+1

while(1):
  index += 1
  tmp_a = func(tmp_a)
  if tmp_a in a:
    break
  else:
    a |= {tmp_a}

print(index)

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

s = int(input())

n = s
for i in range(1000000):
  if n in [1,2,4]:
    print(i+4)
    break
  n = next_num(n)

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


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

a = set()
a.add(s)
m = 1
while True:
    s = f(s)
    m += 1
    if s in a:
        break
    else:
        a.add(s)
print(m)

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

s = int(input())
data = set()
data.add(s)
for i in range(1000010):
    l = len(data)
    val = func(s)
    data.add(val)
    if l == len(data):
        print(i+2)
        break
    s = val

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

f_n = [s]

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

print(len(f_n))

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


def main():
    s = int(input())
    memo = set([s])
    cnt = 1
    while True:
        cnt += 1
        s = f(s)
        if s in memo:
            break
        memo.add(s)
    print(cnt)


if __name__ == "__main__":
    main()

Solution (Python):
prev = int(input())
count = 1
found = False
my_dict = {}
my_dict[prev] = 1

while not found:
    prev = int(prev / 2) if 0 == prev % 2 else 3 * prev + 1
    count += 1
    if not prev in my_dict:
        my_dict[prev] = 1
    else:
        print(count)
        break

Solution (Python):

s = int(input())

a = []
i = 0


def is_not_unique(seq):
    return len(seq)  != len(set(seq))

while True:
    if i == 0:
        a.append(s)
        i += 1
    elif is_not_unique(a):
        out_flag = i
        break 
    elif a[i-1] % 2 == 0:
        a.append(a[i-1] / 2)
        i += 1
    elif a[i-1] % 2 == 1:
        a.append(3 * a[i-1] + 1)
        i += 1
    
def out(x):
    print(x)

out(out_flag)

Solution (Python):
s = int(input())
max_m = 1000000
f = []
f.append(s)
set_f = set(f)

for i in range(1,max_m):
  n = f[i-1]
  if n % 2 == 0:
    f.append(n/2)
  else:
    f.append(3 * n + 1)
  set_f.add(f[i])
  if (len(f) != len(set_f)):
      print(len(f))
      break

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

def f(x):
  if x % 2==0:
    return x//2
  else:
    return 3*x + 1
A = [s]    
flag = True
counter = 0
while flag:
  s = f(s)
  A.append(s)
  B = set(A)
  counter += 1
  if len(B) < len(A):
    flag = False
    print(counter+1)

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

p = {s: 0}

count = 1
n = s
while True:
	count += 1
	if n%2 == 0:
		n = n/2
	else:
		n = (3*n) + 1

	if n in p:
		print(count)
		break
	else:
		p[n] = count

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

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

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


def solve(string):
    s = int(string)
    checks = set([])
    for _ in range(10**6):
        if s in checks:
            break
        else:
            checks.add(s)
            s = collatz(s)
    return str(len(checks) + 1)


if __name__ == '__main__':
    print(solve(input()))

Solution (Python):


s = int(input())

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

progression = []
count = 0
while len(progression) == len(set(progression)):
    if count == 0:
        progression.append(10**5)
    if count == 1:
        progression.append(s)
    if count >= 2:
        f = func(progression[count-1])
        progression.append(f)
    count += 1

print(count-1)

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

Solution (Python):
a0 = int(input())
an = [a0]
def f(n):
        if n%2 == 0:
                return n/2
        else:
                return 3*n + 1
frag = 0
while frag == 0:
        an.append(f(an[-1]))
        for i in range(len(an)-1):
                if an[-1] == an[i]:
                        frag = 1
print(len(an))

Solution (Python):
a0 = int(input())
an = [a0]
def f(n):
        if n%2 == 0:
                return n/2
        else:
                return 3*n + 1
frag = 0
term = 1
while frag == 0:
        an.append(f(an[-1]))
        term += 1
        for i in range(len(an)-1):
                if an[-1] == an[i]:
                        frag = 1
                        break
print(term)

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

a = [s]

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

	a.append(now)
	i += 1

Solution (Python):
f=1
g=0
s=[]
def suretsu(n):
    if n%2==0:
        return n/2
    else:
        return 3*n+1
s.append(int(input()))
while g==0:
    f+=1
    s.append(int(suretsu(s[len(s)-1])))
    for i in range(len(s)-2):
        if s[len(s)-1]==s[i]:
            g=1
            break
print(f)

Solution (Python):
def appear_twice(L):
	return len(L) == len(set(L))

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

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

i = 1
while appear_twice(a_seq):
	a_seq.append(f(a_seq[-1]))
	i = i + 1

print(i)

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 i in range(1,1000001):
  if f(a[i-1]) in a:
    print(i+1)
    break
  else:
    a.append(f(a[i-1]))

Solution (Python):
def func(n):
    if n % 2 == 0:
        return n / 2

    return 3 * n + 1

if __name__ == "__main__":
    s = int(input())
    num_pool = set([s])
    m = 1
    while True:
        s = func(s)
        m += 1
        if s in num_pool:
            break
        
        num_pool.add(s)

    print(m)

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

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


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


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

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

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

l = []
ans = 0

while n not in l:
    l.append(n)
    ans+=1
    n = func(n)

print(ans+1)

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

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

Solution (Python):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))

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

s = ri()

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

Solution (Python):






import numpy as np





s = int(input())





a = np.array([])
a = np.append(a, s)
count = 1

while True:
    count += 1
    if a[-1] % 2 == 0:
        a = np.append(a, a[-1]/2)
    else:
        a = np.append(a, a[-1]*3 + 1)
    
    if (a[-1] == a[:-1]).any():
        print(count)
        break

Solution (Python):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))

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

s = ri()

t = [0 for _ in range(1000000)]

ans = 0
a = s
for i in range(1,1000000):
    if t[int(a)] == 1:
        ans = i
        break
    else:
        t[int(a)] = 1
    a = f(a)

print(ans)

Solution (Python):

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

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

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

s = int(input())

num = genetarete_num(s)

if num == s:
    print(2)
    exit()

num_list = [s,num]

for i in range(3,1000001):
    num = genetarete_num(num)
    if num in num_list:
        print(i)
        exit()
    num_list.append(num)

Solution (Python):
s = int(input())
i = 1
d = set()
d.add(s)

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

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



a = set()


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


def r(s):
    if s in a:
        print(len(a) + 1)
    else:
        a.add(s)
        s = f(s)
        r(s)


r(s)

Solution (Python):
from collections import defaultdict
import sys

import math

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

def sol(a):
    dp = [a]
    
    for i in range(1, 1000000+1):
        x = dp[i-1]
        ans = f(x)
        if ans in dp:
            
            return i+1
        else:
            dp.append(ans)
    return None




do_submit = True

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(int, line.split())) for line in lines]
    a = parsed_lines[0]
    return a[0]


if not do_submit:
    a= input_parse("""
    54
    """)
    print(sol(a))
else:
    
    
    a = list(map(int, input().split()))
    print(sol(a[0]))

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

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

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


for i, v in enumerate(l):
    for j in range(i + 1, len(l) - i):
        if l[j] == v:
            print(j + 1)
            exit()

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

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

while(a.count('1') != 2):
  a.append(func(a[-1]))
  for i in range(len(a) - 1):
    if a[-1] == a[i]:
      print(len(a))
      exit()

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

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

Solution (Python):

s = int(input())

val = s
mp = {s:1}
i= 1
while True:
  i+=1
  if val%2==0:
    val = val//2
  else:
    val = 3*val+1
  
  if val in mp:
    print(i)
    break
  else:
    mp[val] = 1

Solution (Python):
import sys
a = int(input())
numlist = [a]
for i in range(2,500):
    if a % 2 ==0:
        a //= 2
        numlist.append(a)
    else:
        a = a*3 + 1
        numlist.append(a)

kind = {}
count = 0
for s in numlist:
    count += 1
    if s in kind:
        print(count)
        sys.exit()
    else:
        kind[s] = 1

Solution (Python):
import sys
a = int(input())
numlist = [a]
for i in range(2,1000):
    if a % 2 ==0:
        a //= 2
        numlist.append(a)
    else:
        a = a*3 + 1
        numlist.append(a)

kind = {}
count = 0
for s in numlist:
    count += 1
    if s in kind:
        print(count)
        sys.exit()
    else:
        kind[s] = 1

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

Solution (Python):


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

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

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

while True:
    ln.append(f(ln[-1]))
    if f(ln[-1]) in ln:
        break
    else:
        pass
print(len(ln)+1)

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

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

while True:
  m +=1
  a = f(a)
  if a in _set:
    print(m)
    break
  else:
    _set.add(a)
    continue

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

an = int(input())
i = 2
res = []
res.append(an)
while(True):
    am = f(res[-1])
    if am in res:
        print(i)
        break
    res.append(am)
    i += 1