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

int main(){
  int N;
  cin >> N;
  int ans=1;
  for (int i=2;i<=sqrt(N);i++){
    for (int j=2;pow(i,j)<=N;j++){
      ans=max(ans,int(pow(i,j)));
    }
  }
  cout << ans << endl;
}
