object Main extends App{
import scala.math._

val x = scala.io.StdIn.readInt()

var max_b:Double = 0
for (i<-1 to x) {
  val q = (log(x)/log(i)).toInt
  if (q !=1) {
      val b = pow(i,(log(x)/log(i)).toInt)
      max_b = max(max_b, b)
  }
}
println(max_b.toInt)
}