N = int(input()) t = '' while N > 0: t += str(N % 7) N //= 7 if t: print(t[::-1]) else: print(0)