N=int(input()) ls=[] while True: Nm=N%7 ls.append(Nm) N=N//7 if N<7: ls.append(N) break ls.reverse() for i in ls: print(i,end="")