import scala.io.StdIn
object Main extends App {
  // def calcPows(n:Int) = 
  val x = StdIn.readLine.toInt
  val r = math.sqrt(x).toInt
  val ans = (2 to r).map { i =>
    val e: Seq[Int] = for {
      j <- (2 to r)
      e = math.pow(i,j).toInt if(e <= x)
    } yield e
    e.max
  }
  println(ans.max)
}