#include <iostream>

using namespace std;


int main()
{
	int X;
	cin >> X;
	int m = 1;
	for (int i = 2; i < 32; i++) {
		int y = i * i;
		for (;y <= X; y *= i) {
			if (m < y) m = y;
		}
	}
	cout << m << endl;
	return 0;
}