import java.util.Scanner

import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val X = sc.nextInt

    val s = mutable.HashSet(1)
    for (i <- 2 to 1000) {
      var n = i * i
      while (n <= 1000) {
        s += n
        n *= i
      }
    }
    s.toList.filter(_ <= X).max.toString
  }
}
