N = int(input()) a = [] while N > 0: a.append(str(N % 7)) N //= 7 if len(a) == 0: print(0) else: print(''.join(a[::-1]))