import scala.math.pow

object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val max = sc.nextInt() match {
    case 1 => 1
    case x => 
      (for (i <- 2 to x; j <- 2 to x) yield pow(i, j).toInt).filter(_ <= x).max
  }
  println(max) 
}