#include<bits//stdc++.h>
int main(){
	int x, max = 1,p;
	scanf("%d", &x);
	if (x != 1) {
		for (int i = 2; i < x; ++i) {
			p = 2;
			while (pow(i, p) <= x)
			{
				max = fmax(max, pow(i, p));
				++p;
			}
		}
	}
	else max = 1;
	printf("%d", max);
}