function main(input) {
    var x = input[0]-0;
    var ans = 1;
    for(var i=2;i<=x;i++){
        for(var j=2;Math.pow(i,j)<=x;j++){
            ans = Math.max(ans,Math.pow(i,j));
        }
    }
    console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))
