var lines = []; var result = 0;
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
})

rl.on('close', function () {
    var X = Number(lines[0]);
    var ans = 1;
    for (var i = 2; i <= X; i++) {
        if (Math.pow(i, 10) <= X) { ans = Math.pow(i, 10) }
        else if (Math.pow(i, 9) <= X) { ans = Math.pow(i, 9) }
        else if (Math.pow(i, 8) <= X) { ans = Math.pow(i, 8) }
        else if (Math.pow(i, 7) <= X) { ans = Math.pow(i, 7) }
        else if (Math.pow(i, 6) <= X) { ans = Math.pow(i, 6) }
        else if (Math.pow(i, 5) <= X) { ans = Math.pow(i, 5) }
        else if (Math.pow(i, 4) <= X) { ans = Math.pow(i, 4) }
        else if (Math.pow(i, 3) <= X) { ans = Math.pow(i, 3) }
        else if (Math.pow(i, 2) <= X) { ans = Math.pow(i, 2) }
        else { }
    }

    console.log(ans);
});