def henkan(n): s = "" while True: s += str(n % 7) n //= 7 if n == 0: break return s[::-1] n = int(input()) print(henkan(n))