"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    
    let answer = 1;
    
    for(let i=2; i<32; i++) {
        let pow = 1;
        let cnt = 0;
        
        while(Math.pow(i, pow) <= N) {
            let temp = Math.pow(i, pow);
            
            // console.log("cnt:" + cnt)
            // console.log("temp;" + temp)
            
            if(temp <= N && cnt > 0) {
                answer = Math.max(answer, temp)
            }
            
            pow++;
            cnt++;
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
