"use strict";

const main = arg => {
    const N = arg.split("\n")[0];
    const powerOf = [1]; 
    
    for(let i=2; i<=32; i++) {
        let pow = 2;
        while(Math.pow(i, pow) <= N) {
            powerOf.push(Math.pow(i,pow));
            pow++;
        }
    }
    
    console.log(Math.max(...powerOf));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));