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())
s_ = s
counter = 0

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

Solution (Python):
s = int(input())
s_ = s
x = [s]
counter = 0


for _ in range(1000000):
  if s%2 ==0:
    s = s/2
    x.append(s)
  else:
      s = 3*s+1
      x.append(s)


if s_ == 4 or s_ == 2 or s_ == 1:
  print(4)
else:
  print(x.index(4)+4)

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

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

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

list=[]
i=0
list.append(s)

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

Solution (Python):
a = int(input())
ans = {}
flag = 1
while True:
    if a in ans:
        print(flag)
        break
    else:
        ans[a] = 1
    if a % 2 == 0:
        a = a // 2
    else:
        a = 3 * a + 1
    flag += 1

Solution (Python):
N=int(input())
def f(n):
    if n%2==0:
        return int(n/2)
    else:
        return 3*n+1
tmp=[N]
i=1
while True:
    i+=1
    N=f(N)
    if N in tmp:
        break
    else:
        tmp.append(N)
print(i)

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):
s=int(input())
l=[s]
ans=2
while True:
  if s%2:
    s=3*s+1
  else:
    s=s//2
  if s in l:
    break
  else:
    l.append(s)
    ans+=1
print(ans)

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

a = [10 ** 10]
i = 1
temp = 10 ** 10
while True:
    if i == 1:
        temp = s
    elif a[i - 1] % 2 == 0:
        temp = a[i - 1] // 2
    else:
        temp = 3 * a[i - 1] + 1

    if temp in a:
        print(i)
        exit()
    a.append(temp)
    i += 1

Solution (Python):
N = int(input())
Flag = 0
nList = []
nList.append(N)
i = 2
while Flag==0:
  Tmp = N % 2
  TmpN = N
  if Tmp == 0:
    TmpN /= 2
  else:
    TmpN = 3 * N + 1
  
  if TmpN in nList:
    Flag = 1
    break
  else:
    nList.append(TmpN)
    N = TmpN
    i += 1

print(i)

Solution (Python):
s = int(input())
hashtable = {s:1}
counter = 1
flag = True
while flag:
    if s%2 == 0:
        s /= 2
    else:
        s = 3*s + 1
    counter += 1
    
    if s in hashtable.keys():
        flag = False
    else:
        hashtable[s] = 1
    
print(counter)

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

Solution (Python):
s = int(input())
ans = [s,]

for i in range(1,100000):
    if ans.count(ans[-1]) >= 2:
        print(len(ans))
        break
    else:
        if ans[i-1]%2 == 0:
            g = ans[i-1]/2
            ans.append(g)
        elif  ans[i-1]%2 != 0:
            g = 3*ans[i-1]+1
            ans.append(g)

Solution (Python):
import collections

s = int(input())
A = [s]
for i in range(1000000+1):
  A.append(A[i]//2 if A[i]%2==0 else 3*A[i]+1)
  c = collections.Counter(A)
  if c.most_common()[0][1] == 2:
    print(len(A))
    break

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

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

Solution (Python):
s = int(input())
ss = list()
ss += [s]
ans = 1
for i in range(1000000000):    
    if s%2 == 0:
        s = s//2
    else:
        s = 3*s+1
    ss += [s]
    ans +=1
    if s in ss[:-1]:
        print(ans)
        break

Solution (Python):
def solve():
    s = int(input())
    collatz = [s]
    now = s
    for _ in range(10 ** 6):
        a_i1 = 3 * now + 1 if now % 2 else now // 2
        now = a_i1
        if a_i1 in collatz:
            return len(collatz) + 1
        collatz.append(a_i1)


if __name__ == "__main__":
    print(solve())

Solution (Python):

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

print(i)

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

from collections import defaultdict
dic = defaultdict(int)

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

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

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

Solution (Python):
s = int(input())
A = {s}
before = s
for i in range(2, 1000001):
    if before % 2:
        fn = 3 * before + 1
    else:
        fn = before // 2
    if fn in A:
        print(i)
        exit()
    else:
        A.add(fn)
        before = fn

Solution (Python):
import math
import copy

inputa = input().split()



a = int(inputa[0])




















numList = [-1, float(a)]

cnt = 1
flg = True
while cnt < 1000000 and flg == True:
    cnt += 1
    if numList[cnt-1] % 2 == 0:
        numList.append(float(numList[cnt -1] / 2))
    else:
        numList.append(float(3*numList[cnt-1] + 1))

    for i in range(1, cnt):
        if numList[i] == numList[cnt]:
            print(cnt)
            flg = False
            break

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

i = 1
while s != 4 and s != 2 and s != 1:
    i += 1
    if s % 2 == 0:
        s = int(s//2)
    else:
        s = 3*s + 1

print(i+3)

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

dd={s:1}
ans=-1
m=1
while True:
  m+=1
  if s%2>0: s=3*s+1
  else: s=s//2
  
  ans=dd.get(s)
  if ans==None: dd[s]=m
  else: ans=m; break


print(ans)

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

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

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

a.append(s)
i = 1

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

    if a.count(a[i]) > 1:
        print(i+1)
        break
    else:
        i += 1

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

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

else:
  print ("not found")

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

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

num = [p]

count = 1

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

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

if N == 1:
	ans = 3
elif N == 2:
	ans = 3
else:
	ans = 1
	while N != 1:
		if N%2 == 0:
			N = N//2
			ans += 1
		else:
			N = 3*N+1
			ans += 1

print(ans+1)

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


s = int(input())
a = {s}
last = s
i = 2
while True:
    last = f(last)
    if last in a:
        print(i)
        break
    a.add(last)
    i += 1

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(3*a[i]+1)
    if a[-1] in a[:i-1]:
        print(i+2)
        break

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

Solution (Python):
s = int(input())
s_list = []
if s != 1 or s != 2:
    while s != 1:
        if s % 2 == 0:
            s = s / 2
        else:
            s = 3 * s + 1
        s_list.append(s)
    print(max(len(s_list)+2, 4))
else:
    print(4)

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

a = []
i = 0
a.append(s)
cnt = 1
while True:
    t = 0
    if a[i] % 2 == 0:
        t = a[i]//2
    else:
        t = 3*a[i]+1
    for j in range(len(a)):
        if a[j] == t:
            print(i+2)
            exit()
    a.append(t)
    i += 1

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

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

nums=[s]

i=1

while True:
    if nums[i-1]%2==0:
        nums.append(int(nums[i-1]/2))

    else:
        nums.append(int(nums[i-1]*3+1))

    if nums.count(nums[i])==2:
        
        print(i+1)
        exit()

    i+=1

Solution (Python):
a = []
a.append(int(input()))

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

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

Solution (Python):

s = int(input())
ptn = []
n = 1
while True:
    ptn.append(s)

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

    if fn in ptn:
        print(n+1)
        exit()

    ptn.append(fn)
    n += 1
    s = fn

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

a = [0,int(input())]

for i in range(2,10**6):
    x = func(a[i-1])
    if x in a:
        print(i)
        break
    else:
        a.append(x)

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

a = [0]
for i in range(1,10**6):
    if i == 1:
        x = s
    else:
        x = func(a[i-1])
    if x in a:
        print(i)
        break
    else:
        a.append(x)

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

X = [s]
m = 1
next = s

while True:
  m += 1
  next = f(next)
  if next in X:
    break
  else:
    X.append(next)
    
print(m)

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

X = [s]
cont = 1
next = s

while cont < 1000:
  cont += 1
  next = f(next)
  if next in X:
    break
  else:
    X.append(next)
    
print(cont)

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

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

m = 1
while True:
    if s in se:
        ans = m
        break
    m +=1
    se.add(s)
    if s % 2 == 0:
        s = s//2
    else:
        s = s*3+1
print(ans)

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

Solution (Python):
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

"""

a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 



    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())


    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  
"""

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

if __name__ == "__main__":
    s = int(sys.stdin.readline())
    cnt = 0
    nums = set()
    while True:
        nums.add(s)
        cnt += 1
        s = f(s)
        if s in nums:
            
            print(cnt + 1)
            exit()

Solution (Python):
s = int(input())
array = []
array.append(s)
m = 1

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

while (f(s) in array) == False:
    array.append(f(s))
    s = f(s)
    m += 1

print(m+1)

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

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

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

Solution (Python):
s = int(input())
count = 1
st = set()
st.add(s)
while True:
  count += 1
  if s % 2 == 1:
    a  = 3*s + 1
  else:
    a = s / 2
  if a in st:
    break
  st.add(s)
  s = a
print(count)

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

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

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

Solution (Python):
import sys
s = int(input())
aaa = [s]
a_now = s
for i in range(2,1000000):
  if a_now%2 == 0:
    a_next = a_now/2
  else:
    a_next = 3 * a_now + 1
  if a_next in aaa:
    print(i)
    sys.exit()
  aaa.append(a_next)
  a_now = a_next

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

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

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

Solution (Python):
"""


 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())


 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  


a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    s= int(sys.stdin.readline())
    c=1
    l=[]

    while True:
        if l.count(s)>0:
            print(c)
            exit()
        else:
            l.append(s)

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

Solution (Python):
import copy
s = int(input())
l =[s]
lold = copy.deepcopy(l)

for i in range(1000000):

    if l[-1]%2 == 0:
        l.append(l[-1]//2)
    else:
        l.append(3*l[-1] + 1)
    if l[-1] in lold:
        print(len(l))
        exit()
    lold = copy.deepcopy(l)

Solution (Python):
s = int(input())
a = s
b = set()
b.add(a)
m = 1
while m <= 10**6:
    if a%2 == 1:
        if 3*a+1 in b:
            m += 1
            print(m)
            break
        else:
            b.add(3*a+1)
            a = 3*a+1
            m += 1
    else:
        if a//2 in b:
            m += 1
            print(m)
            break
        else:
            b.add(a//2)
            a = a//2
            m += 1

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

while True:

    if a[i] % 2 == 0:
        a.append(a[i]/2)
    else:
        a.append(a[i]*3+1)
    if a[i] == 4:
        print(i+4)
        exit()
    elif a[i] == 2 or a[i] == 1:
        print(i+4)
        exit()

    i += 1

print(a)

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

Solution (Python):
s = int(input())
ansli = [s]
flg = True
cnt = 2
def f(n):
    if n%2 == 0:
        return int(n/2)
    else:
        return (3*n)+1
cnt = 2
cur = s
while flg:
    cur = f(cur)
    if cur in ansli:
        print(cnt)
        flg = False
    else:
        ansli.append(cur)
        cnt += 1

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

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

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

while 1:
    if s%2==0:
        s=s/2
        a.append(s)
    else:
        s=3*s+1
        a.append(s)
    if len(a)!=len(set(a)):
        print(len(a))
        exit()

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):
s=int(input())

def even(n):
    return n/2

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

flag=True
num=[s]

i=1
while flag:
    if s%2 ==0:
        s=even(s)
        if s in num:
            print(i+1)
            flag=False
        else:
            num.append(s)
            i+=1
    else:
        s=odd(s)
        if s in num:
            print(i+1)
            flag=False
        else:
            num.append(s)
            i+=1

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

a = [b]
prev = b
idx = 1
while True:
    fa = prev // 2 if prev % 2 == 0 else 3 * prev +1 
    if fa in a:
        print(len(a) + 1)
        break
    a.append(fa)
    prev = fa

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

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

print(len(l)+1)

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

    if li[i] in li[:i]:
        break
    else:
        i += 1
print(len(li))

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

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

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

print(t+2)

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


ref = [int(input())]
cnt = 1

while True:
    cnt += 1
    dup = f(ref[-1])
    if dup in ref:
        print(cnt)
        exit(0)
    else:
        ref.append(dup)

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

Solution (Python):
ans = [False] * 200000

def collatz(n, i):
    ans[n] = True
    next_val = n//2 if n % 2 == 0 else 3*n+1
    if ans[next_val]: return i+1
    return collatz(next_val, i+1)

def solve():
    s = int(input())
    print(collatz(s, 1))
    
solve()

Solution (Python):
def f(n):
  if n%2:
    return 3*n+1
  else:
    return n//2
ref=[int(input())]
c=1
while True:
  c+=1
  i=f(ref[-1])
  if i in ref:
    print(c);break
  else:
    ref.append(i)

Solution (Python):

def gen(n):
    for _ in range(1000):

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


def main():
    N = int(input())
    a=gen(N)
    post = [N]
    for i,generated in enumerate(a):
        if generated in post:
            print(i+2)
            exit()
        else:
            post.append(generated)

        
    
if __name__== "__main__":
    main()

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

List = []
c = s
while c <= 10**7:
    if c in List:
        ans = len(List)+1
        break
    else:
        List.append(c)
        if c % 2 == 0:
            c = c*0.5
        else:
            c = 3*c+1

print(ans)

Solution (Python):

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

s = int(input())
A = []
A.append(s)
for i in itertools.count(1):
    A.append(f(A[i-1]))
    if A[i] in A[:-1]:
        print(i+1)
        break

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

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

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

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

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

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

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


s = int(input())
a = [s]
while True:
    x = f(a[-1])
    if x in a:
        print(len(a) + 1)
        exit()
    a.append(x)

Solution (Python):

a=int(input())

def gen(a):
    while True:
        yield a
        a = a // 2 if a % 2 == 0 else a * 3 + 1

seen = set()

for ix, x in enumerate(gen(a)):
    if x in seen:
        print(ix+1)
        break
    seen.add(x)

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

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

check = 0
check_list = []
i = 0

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

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

ai = s
a = [ai]

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

print(n)

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

Solution (Python):
s=list(map(int,input().split()))

for i in range(1,10000):
  if s[i-1]%2==0:
    s.append(int(s[i-1]/2))
  elif s[i-1]%2==1:
    s.append(3*s[i-1]+1)
  if s[i] in s[:i]:
    break
print(i+1)

Solution (Python):


s = int(input())

a = [0]

a.append(s)

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

    if x in a:
        print(len(a))
        break
    else:
        a.append(x)

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

while True:
    next = collatz(pre)
    if next not in a:
        m += 1
        a.append(next)
        pre = next
    else:
        break

print(m)

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

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

print(len(a))

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

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

Solution (Python):
def f(x):
  if x%2:
    return 3*x+1
  else:
    return x//2
s = int(input())
result = [s]
count = 1
while True:
  can = f(result[-1])
  if can in result:
    print(count+1)
    break
  else:
    result.append(can)
    count += 1

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

x=[]
x.append(s)

chk=0
cnt=0

while chk==0: 
	cnt+=1
	if x[cnt-1]%2==0:
		x.append(x[cnt-1]//2)
	else:
		x.append(x[cnt-1]*3+1)
	if len(set(x))<cnt:
		print(cnt)
		chk=1

Solution (Python):
s = int(input())
ans = [s]
flag = True
while (flag):
    if not(ans[-1] % 2):
        ans.append(int(ans[-1] / 2))
    else:
        ans.append(3 * ans[-1] + 1)
    if ans.count(ans[-1]) == 2:
        flag = False
        print(len(ans))

Solution (Python):
s = int(input())
ans = 0
if s == 1 or s == 2:
    print(4)
    exit()
for i in range(1000000):
    if s == 4:
        ans = i + 4
        break
    if s % 2 == 0:
        s //= 2
    else:
        s = s * 3 + 1
print(ans)

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

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())
i=1
if s==1: print(4)
elif s==2: print(4)
else:
    while s!=4:
        i+=1
        if s%2==0: s=s/2
        else: s=3*s+1
    print(i+3)

Solution (Python):

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


S = int(input())
i = 2
flag = True
list = [S]
while flag == True:
    S = next_number(S)
    
    
    if S in list:
        print(i)
        break
    else:
        list.append(S)
        i += 1

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    a = LI()
    a.sort()
    print(a[0]*a[1]//2)  
    return


def B():
    d = defaultdict(int)
    s = II()
    def f(n):
        if n % 2:
            return 3 * n + 1
        return n // 2
    i = 1
    while not d[s]:
        d[s] = 1
        s = f(s)
        i += 1
    print(i)
    return


def C():
    return


def D():
    return


if __name__ == '__main__':
    B()

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

f = [s]

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

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

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

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

sets = set([s])
count = 1
a = s
while 1:
    count += 1
    if a % 2==0:
        a = a // 2
    else:
        a = a*3 + 1

    if a in sets:
        print(count)
        break
    else:
        sets.add(a)

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

c=0
num=s
n=[num]
while c==0:
    if num%2==0:
        num=num/2
    else:
        num=3*num+1
    if num in n:
        print(len(n)+1)
        c=1
    else:
        n.append(num)

Solution (Python):
s = int(input())
integers = {s}
count = 1
while True:
    count += 1
    if s % 2 == 0:
        tmp = s / 2
    else:
        tmp = 3 * s + 1
    if tmp in integers:
        break
    integers.add(tmp)
    s = tmp
print(count)

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

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

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

arr = []

for i in range(1000000):
    if num in arr:
        break
    elif num%2==0:
        arr.append(num)
        num = int(num/2)
    elif num%2==1:
        arr.append(num)
        num = num*3 + 1

print(len(arr)+1)