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).view
        j <- 2.to(x).view
      } yield math.pow(i, j).toInt).filter(_ <= x).max
  }
  println(max)
}
