fun main(args: Array<String>){
    val X = readLine()!!.toInt()
    var max: Int = 1
    for (b in 1 until 33){
        var num: Int = b
        for (p in 2 until 10){
            num *= b
            if (num <= X && num > max){
                max = num
            }
        }
    }
    println(max)
}