N = input() ans = [] while N > 0: ans.append(N%7) N /= 7 ans.reverse() unko = 0 print "".join(map(str,ans))