N=int(input()) ANS=0 for i in range(11): ANS*=10 if N>=7**(11-i): ANS+=N//(7**(11-i)) N%=(7**(11-i)) ANS*=10 ANS+=N print(ANS)