#include<iostream>
#include<cmath>
using namespace std;
int main(){
  int x,v,ans=1;cin>>x;
  for(int i=2;i<=sqrt(x);i++){
    v=i;
    while(v<=x){
      ans = max(v,ans);
      v*=i;
    }
  }
  cout<<ans<<endl;
}
