	import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int X = sc.nextInt();

		sc.close();

		int ans = 0;
		for (int b = 1; b <= 1000; b++) {
			for (int p = 2; p <= 10; p++) { //2^10 == 1024なので、10まで調べればX<=1000の範囲はおｋ
				long z = (long) Math.pow(b, p);
				if (z <= X) {
					ans = Math.max(ans, (int) z);
				}
			}
		}
		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

} import java.io.InputStream; InputStream java.io import java.io.PrintStream; PrintStream java.io import java.util.Scanner; Scanner java.util public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int X = sc.nextInt();

		sc.close();

		int ans = 0;
		for (int b = 1; b <= 1000; b++) {
			for (int p = 2; p <= 10; p++) { //2^10 == 1024なので、10まで調べればX<=1000の範囲はおｋ
				long z = (long) Math.pow(b, p);
				if (z <= X) {
					ans = Math.max(ans, (int) z);
				}
			}
		}
		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

} Main InputStream in = System.in; in System.in System System.in PrintStream out = System.out; out System.out System System.out public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int X = sc.nextInt();

		sc.close();

		int ans = 0;
		for (int b = 1; b <= 1000; b++) {
			for (int p = 2; p <= 10; p++) { //2^10 == 1024なので、10まで調べればX<=1000の範囲はおｋ
				long z = (long) Math.pow(b, p);
				if (z <= X) {
					ans = Math.max(ans, (int) z);
				}
			}
		}
		out.println(ans);

	} _main {
		Scanner sc = new Scanner(in);

		int X = sc.nextInt();

		sc.close();

		int ans = 0;
		for (int b = 1; b <= 1000; b++) {
			for (int p = 2; p <= 10; p++) { //2^10 == 1024なので、10まで調べればX<=1000の範囲はおｋ
				long z = (long) Math.pow(b, p);
				if (z <= X) {
					ans = Math.max(ans, (int) z);
				}
			}
		}
		out.println(ans);

	} Scanner sc = new Scanner(in); sc new Scanner(in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc sc.close() sc.close sc int ans = 0; ans 0 for (int b = 1; b <= 1000; b++) {
			for (int p = 2; p <= 10; p++) { //2^10 == 1024なので、10まで調べればX<=1000の範囲はおｋ
				long z = (long) Math.pow(b, p);
				if (z <= X) {
					ans = Math.max(ans, (int) z);
				}
			}
		} int b = 1; int b = 1; b 1 b <= 1000 b 1000 b++ b++ b {
			for (int p = 2; p <= 10; p++) { //2^10 == 1024なので、10まで調べればX<=1000の範囲はおｋ
				long z = (long) Math.pow(b, p);
				if (z <= X) {
					ans = Math.max(ans, (int) z);
				}
			}
		} {
			for (int p = 2; p <= 10; p++) { //2^10 == 1024なので、10まで調べればX<=1000の範囲はおｋ
				long z = (long) Math.pow(b, p);
				if (z <= X) {
					ans = Math.max(ans, (int) z);
				}
			}
		} for (int p = 2; p <= 10; p++) { //2^10 == 1024なので、10まで調べればX<=1000の範囲はおｋ
				long z = (long) Math.pow(b, p);
				if (z <= X) {
					ans = Math.max(ans, (int) z);
				}
			} int p = 2; int p = 2; p 2 p <= 10 p 10 p++ p++ p { //2^10 == 1024なので、10まで調べればX<=1000の範囲はおｋ
				long z = (long) Math.pow(b, p);
				if (z <= X) {
					ans = Math.max(ans, (int) z);
				}
			} { //2^10 == 1024なので、10まで調べればX<=1000の範囲はおｋ
				long z = (long) Math.pow(b, p);
				if (z <= X) {
					ans = Math.max(ans, (int) z);
				}
			} long z = (long) Math.pow(b, p); z (long) Math.pow(b, p) Math.pow Math b p if (z <= X) {
					ans = Math.max(ans, (int) z);
				} z <= X z X {
					ans = Math.max(ans, (int) z);
				} ans = Math.max(ans, (int) z) ans Math.max(ans, (int) z) Math.max Math ans (int) z out.println(ans) out.println out ans String[] args args public static void main(String[] args) {
		new Main()._main(args);
	} main {
		new Main()._main(args);
	} new Main()._main(args) new Main()._main new Main() args String[] args args public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int X = sc.nextInt();

		sc.close();

		int ans = 0;
		for (int b = 1; b <= 1000; b++) {
			for (int p = 2; p <= 10; p++) { //2^10 == 1024なので、10まで調べればX<=1000の範囲はおｋ
				long z = (long) Math.pow(b, p);
				if (z <= X) {
					ans = Math.max(ans, (int) z);
				}
			}
		}
		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

} public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int X = sc.nextInt();

		sc.close();

		int ans = 0;
		for (int b = 1; b <= 1000; b++) {
			for (int p = 2; p <= 10; p++) { //2^10 == 1024なので、10まで調べればX<=1000の範囲はおｋ
				long z = (long) Math.pow(b, p);
				if (z <= X) {
					ans = Math.max(ans, (int) z);
				}
			}
		}
		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

} Main
	import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int X = sc.nextInt();

		sc.close();

		int ans = 0;
		for (int b = 1; b <= 1000; b++) {
			for (int p = 2; p <= 10; p++) { //2^10 == 1024なので、10まで調べればX<=1000の範囲はおｋ
				long z = (long) Math.pow(b, p);
				if (z <= X) {
					ans = Math.max(ans, (int) z);
				}
			}
		}
		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}
