N = int(input()) ans = [] for i in reversed(range(100)): ans.append(str(N//pow(7, i))) N %= pow(7, i) print(int("".join(ans)))