n=int(input()) ans = [] while n > 0: ans.append(str(n%7)) n//=7 print(''.join(ans[::-1]) if n != 0 else 0)