num = int(input())
if 0 < num < 6:
    print(num)
a = ""
while num >= 6:
    b, c = num // 6, num % 6
    a += str(c)
    if b < 6:
        a += str(b)
    num = b
print(a[::-1])