#include<bits/stdc++.h>
using namespace std;

int main() {
  int n; cin>>n;

  int ans = 1;
  for (int i = 2; i*i <= n; i++) {
    int tmp = i;
    while (tmp <= n) tmp*=i;
    tmp /= i;
    ans = max(ans, tmp);
  }
  cout<<ans<<endl;
}
