import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextInt()

    println(abc097b(x))
}

private fun abc097b(x: Int): Int {
  val ansList = mutableListOf<Int>()
  ansList.add(1)

  for (i in 2..31) {
    var tmp = i * i
    while (tmp <= x) {
      ansList.add(tmp)
      tmp *= i
    }
  }

  return ansList.max()!!
}
