function Main(input) {
	var list = [];
	
	for(var i = 0; i < 1000; i++){
		for(var j = 1; j < 6; j++){
			var ret = Math.pow(i,j);
			if(ret < 1000){
				list.push(ret);
			}
		}
	}
	var s = new Set(list);
	var ans = 1;
	for(var i = 0; i < 1000; i++){
		if(s[i] > input){
			console.log(ans)
		} else {
			ans = s[i];
		}
	}
	
	
	var ret = Math.floor(Math.sqrt(input));
	console.log(ret*ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));