'use strict'

const Main = (input) => {
  const X = parseInt(input.trim())

  let resultArr = [1]

  for (let i = 1; i <= X; i++) {
    for (let j = 1; j < Math.sqrt(X); j++) {
      for (let k = 2; k < Math.sqrt(X); k++) {
        if (Math.pow(j, k) === i) {
          if (resultArr.indexOf(i) === -1) {
            resultArr.push(i)
          }
        }
      }
    }
  }

  let result = Math.max.apply(null, resultArr)

  console.log(result)
  return result
}

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