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

int main(void) {
	int x;
	cin >> x;

	int ans = -1, bp;

	for(int b=1;b<=32;b++) {
		for(int p=2;p<=10;p++) {
			bp = pow(b,p);
			if(bp <= x) ans = max(ans, bp);
		}
	}

	cout << ans << endl;

}
