'''
재귀함수 : (recursive function)
정의
1. 함수 내에서 자신을 다시 호출하는 함수 (ok)
2. 자신으로 다시 정의내리는 함수
특징
1. 코드가 짧아.
2. 말이 돼. 근데 왜 되는거지?
'''
# def f(n) : # f(n) : 1 ~ n 출력
# for i in range(1,n+1) :
# print(i)
'''
f(n) : 1 ~ n 출력
: 1출력 -> 2출력 -> ... n-1출력 -> n출력
: 1 ~ n-1 출력 -> n출력
: f(n-1) -> n출력 ( n > 0 일때)
def f(n) :
if n==0 :
return
f(n-1)
print(n)
f(5) # f함수 호출
'''
'''
f(n) : n ~ 1 출력
: n출력 -> n-1 출력 -> .... -> 출력
: n출력 -> n-1~1출력
: n출력 -> f(n-1)
n=int(input())
def f(n) : # n권 책을 뽑아
if n==0 :
return
print(n) # n이라고 말해
f(n-1) # n-1권 책을 뽑아
# n권 책을 닫아
f(n)
f(a,b) : a ~ b 출력
: a ~ b-1 출력 -> b 출력
: f(a, b-1) -> b출력
'''
# a,b=map(int,input().split())
# def f(a,b):
# if a>b:
# return
# f(a,b-1)
# if b%2==1:
# print(b)
# f(a,b)
def f(n):
if n%2==0:
n=n//2
else:
n=3*n+1
print(n)
f(n)