n=int(input()) if n==0: print("0") else: a=[] ans="" while n!=0: a.append(n%7) n//=7 for i in a[::-1]: ans+=str(i) print(ans)