import math N = int(input()) ans = '' m = int(math.log(N, 7) ) for i in range(m, -1, -1): ans += str(N // (7**i)) N %= 7 if ans.startswith('0'): print(ans[1:]) else: print(ans)