program exponential
  implicit none
  integer :: x, n, i, s, t, k
  read(*,*) x
  if (x.lt.4) then
    write(*,'(i0)') 1
    stop
  end if
  k = ceiling(sqrt(real(x,8)))
  s = 0
  do i = 2, k
    t = i*i
    do
      if (t.gt.x) exit
      if (s.lt.t) s = t
      t = t*i
    end do
  end do
  write(*,'(i0)') s
  stop
end program exponential