N = int(raw_input()) ans = '' while N != 0: ans = str(N%7) + ans N /= 7 if ans == '': ans = '0' print ans