n = int(input()) if n == 0: print(0) exit() ans = "" while n >= 1: ans += n % 7 n //= 7 print(int(ans[::-1]))