import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int x = parseInt(sc.next());
		sc.close();
		int mx = 0;
		if(x<4) {
			mx=1;
		} else {
			int sq = (int) floor(sqrt(x));
			int jo=0;
			for (i = 2; i <= sq; i++) {
				jo=(int)pow((double)i,floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%f:%f:%f%n",i,log10((double)x),log10((double)i),floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%d%n",i,jo);
				if(jo>mx)mx=jo;
			}
		}
		out.println(mx);
	}
} import java.util.*; util.* java import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Integer.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int x = parseInt(sc.next());
		sc.close();
		int mx = 0;
		if(x<4) {
			mx=1;
		} else {
			int sq = (int) floor(sqrt(x));
			int jo=0;
			for (i = 2; i <= sq; i++) {
				jo=(int)pow((double)i,floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%f:%f:%f%n",i,log10((double)x),log10((double)i),floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%d%n",i,jo);
				if(jo>mx)mx=jo;
			}
		}
		out.println(mx);
	}
} Main public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int x = parseInt(sc.next());
		sc.close();
		int mx = 0;
		if(x<4) {
			mx=1;
		} else {
			int sq = (int) floor(sqrt(x));
			int jo=0;
			for (i = 2; i <= sq; i++) {
				jo=(int)pow((double)i,floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%f:%f:%f%n",i,log10((double)x),log10((double)i),floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%d%n",i,jo);
				if(jo>mx)mx=jo;
			}
		}
		out.println(mx);
	} main {
		int i,j;
		Scanner sc = new Scanner(in);
		int x = parseInt(sc.next());
		sc.close();
		int mx = 0;
		if(x<4) {
			mx=1;
		} else {
			int sq = (int) floor(sqrt(x));
			int jo=0;
			for (i = 2; i <= sq; i++) {
				jo=(int)pow((double)i,floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%f:%f:%f%n",i,log10((double)x),log10((double)i),floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%d%n",i,jo);
				if(jo>mx)mx=jo;
			}
		}
		out.println(mx);
	} int i i j; j Scanner sc = new Scanner(in); sc new Scanner(in) int x = parseInt(sc.next()); x parseInt(sc.next()) parseInt sc.next() sc.next sc sc.close() sc.close sc int mx = 0; mx 0 if(x<4) {
			mx=1;
		} else {
			int sq = (int) floor(sqrt(x));
			int jo=0;
			for (i = 2; i <= sq; i++) {
				jo=(int)pow((double)i,floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%f:%f:%f%n",i,log10((double)x),log10((double)i),floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%d%n",i,jo);
				if(jo>mx)mx=jo;
			}
		} x<4 x 4 {
			mx=1;
		} mx=1 mx 1 {
			int sq = (int) floor(sqrt(x));
			int jo=0;
			for (i = 2; i <= sq; i++) {
				jo=(int)pow((double)i,floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%f:%f:%f%n",i,log10((double)x),log10((double)i),floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%d%n",i,jo);
				if(jo>mx)mx=jo;
			}
		} int sq = (int) floor(sqrt(x)); sq (int) floor(sqrt(x)) floor sqrt(x) sqrt x int jo=0; jo 0 for (i = 2; i <= sq; i++) {
				jo=(int)pow((double)i,floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%f:%f:%f%n",i,log10((double)x),log10((double)i),floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%d%n",i,jo);
				if(jo>mx)mx=jo;
			} i = 2; i = 2 i 2 i <= sq i sq i++ i++ i {
				jo=(int)pow((double)i,floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%f:%f:%f%n",i,log10((double)x),log10((double)i),floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%d%n",i,jo);
				if(jo>mx)mx=jo;
			} {
				jo=(int)pow((double)i,floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%f:%f:%f%n",i,log10((double)x),log10((double)i),floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%d%n",i,jo);
				if(jo>mx)mx=jo;
			} jo=(int)pow((double)i,floor(log10((double)x)/log10((double)i))) jo (int)pow((double)i,floor(log10((double)x)/log10((double)i))) pow (double)i floor(log10((double)x)/log10((double)i)) floor log10((double)x)/log10((double)i) log10((double)x) log10 (double)x log10((double)i) log10 (double)i if(jo>mx)mx=jo; jo>mx jo mx mx=jo mx jo out.println(mx) out.println out mx String[] args args public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int x = parseInt(sc.next());
		sc.close();
		int mx = 0;
		if(x<4) {
			mx=1;
		} else {
			int sq = (int) floor(sqrt(x));
			int jo=0;
			for (i = 2; i <= sq; i++) {
				jo=(int)pow((double)i,floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%f:%f:%f%n",i,log10((double)x),log10((double)i),floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%d%n",i,jo);
				if(jo>mx)mx=jo;
			}
		}
		out.println(mx);
	}
} public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int x = parseInt(sc.next());
		sc.close();
		int mx = 0;
		if(x<4) {
			mx=1;
		} else {
			int sq = (int) floor(sqrt(x));
			int jo=0;
			for (i = 2; i <= sq; i++) {
				jo=(int)pow((double)i,floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%f:%f:%f%n",i,log10((double)x),log10((double)i),floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%d%n",i,jo);
				if(jo>mx)mx=jo;
			}
		}
		out.println(mx);
	}
} Main
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int x = parseInt(sc.next());
		sc.close();
		int mx = 0;
		if(x<4) {
			mx=1;
		} else {
			int sq = (int) floor(sqrt(x));
			int jo=0;
			for (i = 2; i <= sq; i++) {
				jo=(int)pow((double)i,floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%f:%f:%f%n",i,log10((double)x),log10((double)i),floor(log10((double)x)/log10((double)i)));
//				out.printf("%d:%d%n",i,jo);
				if(jo>mx)mx=jo;
			}
		}
		out.println(mx);
	}
}
