import scala.io.{StdIn => in}

object Main extends App {
  val x = in.readInt
  def rec(acc:Int, b:Int, p:Int):Int = {
    if(b == 1) return acc
    val res = math.pow(b,p).toInt
    // println(res)
    if(res > x) acc
    else rec(res, b, p+1)
  }
  val ans = (1 to math.sqrt(x).toInt + 1)./:(1)( (acc, i) => {
    val y = rec(i, i, 2)
    if(y <= x) acc max y else acc
  })
  println(ans)
}