
object Main {

  def calc(X: Int): Int = {
    var max = 0
    for {
      i <- 1 to math.sqrt(X).toInt
      j <- 2 to math.sqrt(X).toInt
      n = math.pow(i, j).toInt
      if n <= X
    } {
      max = math.max(max, n)
    }
    max
  }

  def main(args: Array[String]): Unit = {
    val in = io.Source.fromInputStream(System.in).getLines()
    val X= in.next().toInt
    System.out.println(calc(X))
  }
}