n=int(input());a=""; while n:a+=str(n%7);n//=7 print(a[::-1]or 0)