program main
  implicit none

  integer :: x, p, b, ans, i, j

  read(*,*) x


  if(x <= 3) then
     ans = 1
     write(*,*) ans
     stop
  end if
  
  ans = 0
  do i = 2, x
     do j = 2, 10
        b = i
        p = j
        if(x >= b**p) then
           ans = max(ans, b**p)
        end if
     end do
  end do

  write(*,*) ans

end program main

     
  
