import Foundation

let x = Int(readLine()!)!
var ans = 0
for i in 2...31 {
  for j in 2...9 {
    let p = pow(Double(i), Double(j))
    if Int(p) <= x { ans = max(Int(p), ans) }
  }
}
print(x < 4 ? 1 : ans)