import math n=int(input()) j=int(math.log(n,7))+1 a=[((n%7**(i+1))//7**i) for i in range(j)] a.reverse() print("".join(str(a) for a in a))