n=int(input())
a=[]
while n!=0:
    m=n%6
    a.append(m)
    n=n//6
for i in (a[::-1]):
    print(i,end="")