import scala.io.StdIn
object Main extends App {
  val x = StdIn.readLine.toInt
  val r = math.sqrt(x).toInt
  val ans = if( r == 1) x else
    (2 to r).map { i =>
      val e = for {
        j <- (2 to r)
        e = math.pow(i,j).toInt if(e <= x)
      } yield e
      e.max
    }.max
  println(ans)
}