n=int(input()) ans=[] while n>=7: ans.append(n%7) n//=7 print(str(n)+''.join(map(str,ans[::-1])))