function Main(s) {
  s = +s;
  var ans = 1;
  for(var i = 2; i < s; i++)
  for(var j = 2; j < s; j++){
    if(Math.pow(i, j) <= s)ans = Math.pow(i, j);
    else break;
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));