N=int(input()) a='' for i in range(11)[::-1]:a+=str(N//7**i);N%=7**i print(int(a))