object Main extends App {
	val x = scala.io.StdIn.readInt

	if(x == 1){
		println(1)
	}else{

		var ans = 0
		for(i<-2 to x){
			
			var tp = i*i
			var tq = 2
			
			while(tp <= x){
				tp = tp * i
				tq += 1
			}

			if(tq != 2){
				ans = math.max(ans, tp/i)	
			}
		}

		println(ans)
	}

}
