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
    power = math.pow(i, j).toInt
    if power <= 1000
  } yield power
  println(powers.distinct.findLast(_ <= X).getOrElse(1))
}
