fun main(args: Array<String>) = yorukatsu23b()

fun yorukatsu23b() {
    val x = readLine()!!.toInt()

    val set = mutableSetOf<Long>()

    for (b in 1..1000L) for (p in 2L..1000) {
        val element = pow(b, p)
        set.add(element)
        if (element > x) break
    }

    val answer = set.filter { it <= x }.max()!!

    println(answer)
}

private fun pow(n: Long, p: Long): Long = (1..p).fold(1L) { acc, i -> acc * n }
