fun main(args: Array<String>) {
    val X = readLine()!!.toInt()

    val l = mutableListOf(1)
    for (p in 1 until 33) for (q in 2 until 10) {
        val d = Math.pow(p.toDouble(), q.toDouble()).toInt()
        if (d <= X) l.add(d)
    }

    println(l.distinct().sorted().reversed().first())
}
