M = int(input())
A = [1]
N = 1
for i in range(M-1):
if N % 3 == 1:
if not(int(((N - 1) / 3)) in A):
if ((N - 1) / 3) != 0:
if ((N - 1) / 3) % 3 != 0:
N = int((N - 1) / 3)
A.append(N)
else:
N *= 2
A.append(N)
else:
N *= 2
A.append(N)
else:
N *= 2
A.append(N)
else:
N *= 2
A.append(N)
print(N)