fun main(args: Array<String>) {
    val x = readLine()!!.toDouble()
    var ans = 0.0
    (1..Math.sqrt(x).toInt()).forEach {
        val b = it.toDouble()
        var s = 0.0
        for (p in 2..9) {
            val t = Math.pow(b, p.toDouble())
            if (x < t) break
            s = t
            if (x == t) break
        }
        ans = Math.max(ans, s)
    }
    println(ans.toInt())
}
