#include<iostream>
using namespace std;
int main(){
	int n;
  	cin >> n;
  	int ans = 1;
  	for(int i = 2; i<n; i++){
		int t = i*i;
    	while(t<=n){
			if(ans<t)ans = t;
			t*=i;
  		}
    }
  	cout << ans << endl;
}
