def main(): N = int(input()) foo_list = [] value = 0 while 7 ** value < N: value += 1 num_of_digit = value - 1 for i in range(num_of_digit): digit = num_of_digit - i value2 = 0 while (7 ** digit) * value2 < N: value2 += 1 foo_list.append(value2 - 1) N = N - (7 ** digit) * (value2 - 1) foo_list.append(N) for i in foo_list: print(i, end='') print() if __name__ == '__main__': main()