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

    val ok = BooleanArray(1001)
    ok[1] = true
    for (b in 2..31) {
        var k = b*b
        while (k<=1000) {
            ok[k] = true
            k *= b
        }
    }

    ok.take(x+1).withIndex().last { it.value }.index

})
