fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    println(getAns(n))
}

fun getAns(num:Int):Int {
    var ret = 1
    for(i in (2..num)) {
        var tmp = i*i
        while (tmp <= num) {
            ret = Math.max(ret, tmp)
            tmp *= i
        }
    }
    return ret
}
