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