object Main {
  import scala.math._

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

var max_b:Double = 0
for (i<-1 to x) {
  if (i==1){
    max_b = max(max_b,1)
  } else {
      var tmp = i*i
      while (tmp <= x){
        max_b = max(max_b, tmp)
        tmp *= i
      }
  }
}
println(max_b.toInt)
}