object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val X = sc.nextInt()
  val powers = for {
    i <- 1 to 31
    j <- 2 to 10 if math.pow(i, j) <= X
  } yield math.pow(i, j).toInt
  println(powers.distinct.findLast(_ <= X).getOrElse(1))
}
