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