import scala.io.StdIn
object Main extends App {
  val x = StdIn.readLine().toInt
  
  var b = 1
  var p = 2
  var max = 1
  while(scala.math.pow(b+1, p)  <= x){
    b += 1
    while(scala.math.pow(b, p+1) <= x){
      p += 1
    }
    max = scala.math.max(max, scala.math.pow(b, p).toInt)
    p = 2
  }
  
  println(max)
}
