program main
  implicit none
  integer :: x, i, j, t, res
  read(*, *) x
  res = 1
  do i = 2, 1000
    do j = 2, 40
      t = i ** j
      if (t > x) exit
      res = max(res, t)
    end do
  end do

  write(*, "(i0)") res

end program main
