n=int(input()) a=[] while n>0: a.append(str(n%7)) n//=7 if len(a)==0: print(0) else: print("".join(a[::-1]))