n = int(input()) x = '' i = 0 while n - 7 >= 0: x = x + str(n % 7) n = int(n / 7) i += 1 x = x + str(n%7) print(x[::-1])