import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int ans = 1;

		for (int b = 1; b <= x; b++) {
			for (int p = 2; p < 1000; p++) {
				int pow = (int)Math.pow(b, p);
				if (pow <= x)
					if (ans < pow) ans = pow;
			}
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int ans = 1;

		for (int b = 1; b <= x; b++) {
			for (int p = 2; p < 1000; p++) {
				int pow = (int)Math.pow(b, p);
				if (pow <= x)
					if (ans < pow) ans = pow;
			}
		}
		System.out.println(ans);
	}
} Main public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int ans = 1;

		for (int b = 1; b <= x; b++) {
			for (int p = 2; p < 1000; p++) {
				int pow = (int)Math.pow(b, p);
				if (pow <= x)
					if (ans < pow) ans = pow;
			}
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int ans = 1;

		for (int b = 1; b <= x; b++) {
			for (int p = 2; p < 1000; p++) {
				int pow = (int)Math.pow(b, p);
				if (pow <= x)
					if (ans < pow) ans = pow;
			}
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int ans = 1; ans 1 for (int b = 1; b <= x; b++) {
			for (int p = 2; p < 1000; p++) {
				int pow = (int)Math.pow(b, p);
				if (pow <= x)
					if (ans < pow) ans = pow;
			}
		} int b = 1; int b = 1; b 1 b <= x b x b++ b++ b {
			for (int p = 2; p < 1000; p++) {
				int pow = (int)Math.pow(b, p);
				if (pow <= x)
					if (ans < pow) ans = pow;
			}
		} {
			for (int p = 2; p < 1000; p++) {
				int pow = (int)Math.pow(b, p);
				if (pow <= x)
					if (ans < pow) ans = pow;
			}
		} for (int p = 2; p < 1000; p++) {
				int pow = (int)Math.pow(b, p);
				if (pow <= x)
					if (ans < pow) ans = pow;
			} int p = 2; int p = 2; p 2 p < 1000 p 1000 p++ p++ p {
				int pow = (int)Math.pow(b, p);
				if (pow <= x)
					if (ans < pow) ans = pow;
			} {
				int pow = (int)Math.pow(b, p);
				if (pow <= x)
					if (ans < pow) ans = pow;
			} int pow = (int)Math.pow(b, p); pow (int)Math.pow(b, p) Math.pow Math b p if (pow <= x)
					if (ans < pow) ans = pow; pow <= x pow x if (ans < pow) ans = pow; ans < pow ans pow ans = pow ans pow System.out.println(ans) System.out.println System.out System System.out ans String args[] args
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int ans = 1;

		for (int b = 1; b <= x; b++) {
			for (int p = 2; p < 1000; p++) {
				int pow = (int)Math.pow(b, p);
				if (pow <= x)
					if (ans < pow) ans = pow;
			}
		}
		System.out.println(ans);
	}
}