N = int(input()) seven = [] if N == 0: print(0) else: while(N > 0): seven.append(str(N % 7)) N //= 7 print(''.join(reversed(seven)))