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