fun main(args:Array<String>) {
	val x = readLine()!!.toInt()
	if(x<=3){
		println(1)
		return
	}
	(2..32).map{ b->
		val bp = mutableListOf<Int>()
		var acc=b*b
		while(acc<=x){
			bp.add(acc)
			acc*=b
		}
		return@map bp
	}.flatten().max().let{ println(it) }
	
}