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