x = int(input())
goal = []
while x != 0:
    b = x%6
    x = int(x/6)
    goal.append(int(b))
for i in reversed(goal):
    print(i,end='')