N=int(input()) ANS="" for i in range(100,-1,-1): ANS+=str(N//(7**i)) N=N%(7**i) while ANS[0]=="0": ANS=ANS[1:] print(ANS)