function Main(input) {
    var X = parseInt(input.split('/n')[0].split(' '), 10);

    var list = [];
    
    for (var i = 2 ; i < 32 ; ++i) {
        for (var j = 2 ; ; ++j) {
            var pow = Math.pow(i, j);
            if (pow <= 1000) list.push(pow);
            else break;
        }
    }
    list.push(1);

    list = list.sort(function(a, b) { return a - b; });

    for (var i = 0 ; i < list.length ; ++i) {
        if (i === list.length - 1 || list[i+1] > X) {
            console.log(list[i]);
            break;
        }
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));