function Main (input) {
  const num = parseInt(input.split(/\s/g)[0]);

  if (num === 1) return console.log('%s', 1);

  const pattern = new Array(num).fill('')
    .map((value1, index1) => {
      return new Array(num).fill('').map((value2, index2) => Math.pow(index1 + 1, index2 + 1));
    })
    .map((values) => (
      values.filter((value, index) => {
        if (index === 0) return false;
        return value <= num;
      })
    ))
    .filter((values) => values.length)
    .map((values) => Math.max(...values));
  console.log('%s', Math.max(...pattern));
}

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