#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
  int x,i,j,t,res=1;
  cin >> x;
  t=(int)sqrt(x);
  for(i=t;i>1;i--){
    j=i;
    while(j*i<=x) j*=i;
    res=max(res,j);
  }
  cout << res << endl;
  return 0;
}