fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val ans = (1..n).filter { isExp(it) }.max()!!
    println(ans)
}


fun isExp(num:Int):Boolean {
    if(num == 1) {
        return true
    }
    for(i in (2..num)) {
        var cnt = 0
        var tmp = num
        if(i*i>num) {
            break
        }
        while (tmp % i == 0) {
            tmp /= i
            cnt++
        }
        if(tmp == 1 && cnt > 1) {
            return true
        }
    }
    return false
}