N=int(raw_input())
seven=[N%7]
Seven=[]
N/=7
while N>0:
    seven.append(N%7)
    N/=7
seven.reverse()
for a in seven:
    Seven.append(str(a))
print "".join(Seven)