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