import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}


fun solve(out: PrintWriter) {
    val x = readInteger()
    val powList = mutableListOf<Int>()
    powList += 1
    var b = 2
    while (b * b <= x) {
        var tmp = b
        while (tmp <= x) {
            powList += tmp
            tmp *= b
        }

        b++
    }
    val aa = powList.sortedDescending().first()
    println(aa)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)
