n=int(input()) if n == 0: print(0) exit() ans = [] while n > 0: ans.append(str(n%7)) n//=7 print(''.join(ans[::-1]))