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