function main(input) {
	const x = input;
	var t = 1;
	for(b=2;b<=1000;b++){
		for(p=2;p<=1000;p++){
			var a = Math.pow(b, p);
			if(a > x){
				a = 0;
				break;
			}
			if(a>t){
				t = a;
			}
		}
		if(a > x){
			break;
		}
	}
	console.log(t);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));