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

    var max = 1
    for (i in 2..32) {
        if (i < X) {
            max = Math.max(max, calc(i, X))
        }
    }
    println(max)

}

private fun calc(x: Int, X: Int): Int {
    var result = x
    while (true) {
        val temp = result * x
        if (temp <= X) {
            result = temp
        } else {
            break
        }
    }
    return result
}