fun main(args: Array<String>) {
    abc097b()
}

fun abc097b() {
    val x = readLine()!!.toInt()

    val answer = (1..32).map { n1 -> (2..10).map { n2 -> Math.pow(n1.toDouble(), n2.toDouble()).toLong() } }
        .flatten().sorted().findLast { it <= x }

    println(answer)
}
