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