n = int(input()) out = "" while n > 0: out = str(n % 7) + out n //= 7 print(out if out != "" else "0")