N = int(input()) if N == 0: print(N) exit() ans = [] while N > 0: ans.append(str(N % 7)) N //= 7 print("".join(ans[::-1]))