N = int(input()) ans = "" while N >= 7: ans = str(N % 7) + ans N //= 7 ans = str(N) + ans print(ans)