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