N = int(input()) if N == 0: print(0) exit() ans = [] while N: ans.append(N%7) N //= 7 ans.reverse() print(*ans, sep="")