N = int(input().strip()) def n7(num): if num == 0: return 0 else: return int(str(n7(num // 7)) + str(num % 7)) print(n7(N))