import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int num = s.nextInt();
		int ans = 1;

		for (int a = 2; a < 32; a++) {

			for (int b = 2; b < 9; b++) {
				if ((int) Math.pow(a, b) <=num) {
					ans = Math.max(ans, (int) Math.pow(a, b));
				}
			}
		}
		System.out.println(ans);

	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int num = s.nextInt();
		int ans = 1;

		for (int a = 2; a < 32; a++) {

			for (int b = 2; b < 9; b++) {
				if ((int) Math.pow(a, b) <=num) {
					ans = Math.max(ans, (int) Math.pow(a, b));
				}
			}
		}
		System.out.println(ans);

	}
} Main public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int num = s.nextInt();
		int ans = 1;

		for (int a = 2; a < 32; a++) {

			for (int b = 2; b < 9; b++) {
				if ((int) Math.pow(a, b) <=num) {
					ans = Math.max(ans, (int) Math.pow(a, b));
				}
			}
		}
		System.out.println(ans);

	} main {
		Scanner s = new Scanner(System.in);
		int num = s.nextInt();
		int ans = 1;

		for (int a = 2; a < 32; a++) {

			for (int b = 2; b < 9; b++) {
				if ((int) Math.pow(a, b) <=num) {
					ans = Math.max(ans, (int) Math.pow(a, b));
				}
			}
		}
		System.out.println(ans);

	} Scanner s = new Scanner(System.in); s new Scanner(System.in) int num = s.nextInt(); num s.nextInt() s.nextInt s int ans = 1; ans 1 for (int a = 2; a < 32; a++) {

			for (int b = 2; b < 9; b++) {
				if ((int) Math.pow(a, b) <=num) {
					ans = Math.max(ans, (int) Math.pow(a, b));
				}
			}
		} int a = 2; int a = 2; a 2 a < 32 a 32 a++ a++ a {

			for (int b = 2; b < 9; b++) {
				if ((int) Math.pow(a, b) <=num) {
					ans = Math.max(ans, (int) Math.pow(a, b));
				}
			}
		} {

			for (int b = 2; b < 9; b++) {
				if ((int) Math.pow(a, b) <=num) {
					ans = Math.max(ans, (int) Math.pow(a, b));
				}
			}
		} for (int b = 2; b < 9; b++) {
				if ((int) Math.pow(a, b) <=num) {
					ans = Math.max(ans, (int) Math.pow(a, b));
				}
			} int b = 2; int b = 2; b 2 b < 9 b 9 b++ b++ b {
				if ((int) Math.pow(a, b) <=num) {
					ans = Math.max(ans, (int) Math.pow(a, b));
				}
			} {
				if ((int) Math.pow(a, b) <=num) {
					ans = Math.max(ans, (int) Math.pow(a, b));
				}
			} if ((int) Math.pow(a, b) <=num) {
					ans = Math.max(ans, (int) Math.pow(a, b));
				} (int) Math.pow(a, b) <=num (int) Math.pow(a, b) Math.pow Math a b num {
					ans = Math.max(ans, (int) Math.pow(a, b));
				} ans = Math.max(ans, (int) Math.pow(a, b)) ans Math.max(ans, (int) Math.pow(a, b)) Math.max Math ans (int) Math.pow(a, b) Math.pow Math a b System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int num = s.nextInt();
		int ans = 1;

		for (int a = 2; a < 32; a++) {

			for (int b = 2; b < 9; b++) {
				if ((int) Math.pow(a, b) <=num) {
					ans = Math.max(ans, (int) Math.pow(a, b));
				}
			}
		}
		System.out.println(ans);

	}
} public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int num = s.nextInt();
		int ans = 1;

		for (int a = 2; a < 32; a++) {

			for (int b = 2; b < 9; b++) {
				if ((int) Math.pow(a, b) <=num) {
					ans = Math.max(ans, (int) Math.pow(a, b));
				}
			}
		}
		System.out.println(ans);

	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int num = s.nextInt();
		int ans = 1;

		for (int a = 2; a < 32; a++) {

			for (int b = 2; b < 9; b++) {
				if ((int) Math.pow(a, b) <=num) {
					ans = Math.max(ans, (int) Math.pow(a, b));
				}
			}
		}
		System.out.println(ans);

	}
}
