import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	    int x = scan.nextInt();
	    scan.close();
	    int pow = 0;
		int ans = 1;
		for (int i = 1; i < x; i++) {
			for (int j = 2; j < x; j++) {
				pow = (int) Math.pow(i, j);
				if (pow <= x) {
					ans = Math.max(ans, pow);
				}
			}
		}
		System.out.println(ans);
	}

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

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	    int x = scan.nextInt();
	    scan.close();
	    int pow = 0;
		int ans = 1;
		for (int i = 1; i < x; i++) {
			for (int j = 2; j < x; j++) {
				pow = (int) Math.pow(i, j);
				if (pow <= x) {
					ans = Math.max(ans, pow);
				}
			}
		}
		System.out.println(ans);
	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	    int x = scan.nextInt();
	    scan.close();
	    int pow = 0;
		int ans = 1;
		for (int i = 1; i < x; i++) {
			for (int j = 2; j < x; j++) {
				pow = (int) Math.pow(i, j);
				if (pow <= x) {
					ans = Math.max(ans, pow);
				}
			}
		}
		System.out.println(ans);
	} main {
		Scanner scan = new Scanner(System.in);
	    int x = scan.nextInt();
	    scan.close();
	    int pow = 0;
		int ans = 1;
		for (int i = 1; i < x; i++) {
			for (int j = 2; j < x; j++) {
				pow = (int) Math.pow(i, j);
				if (pow <= x) {
					ans = Math.max(ans, pow);
				}
			}
		}
		System.out.println(ans);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan scan.close() scan.close scan int pow = 0; pow 0 int ans = 1; ans 1 for (int i = 1; i < x; i++) {
			for (int j = 2; j < x; j++) {
				pow = (int) Math.pow(i, j);
				if (pow <= x) {
					ans = Math.max(ans, pow);
				}
			}
		} int i = 1; int i = 1; i 1 i < x i x i++ i++ i {
			for (int j = 2; j < x; j++) {
				pow = (int) Math.pow(i, j);
				if (pow <= x) {
					ans = Math.max(ans, pow);
				}
			}
		} {
			for (int j = 2; j < x; j++) {
				pow = (int) Math.pow(i, j);
				if (pow <= x) {
					ans = Math.max(ans, pow);
				}
			}
		} for (int j = 2; j < x; j++) {
				pow = (int) Math.pow(i, j);
				if (pow <= x) {
					ans = Math.max(ans, pow);
				}
			} int j = 2; int j = 2; j 2 j < x j x j++ j++ j {
				pow = (int) Math.pow(i, j);
				if (pow <= x) {
					ans = Math.max(ans, pow);
				}
			} {
				pow = (int) Math.pow(i, j);
				if (pow <= x) {
					ans = Math.max(ans, pow);
				}
			} pow = (int) Math.pow(i, j) pow (int) Math.pow(i, j) Math.pow Math i j if (pow <= x) {
					ans = Math.max(ans, pow);
				} pow <= x pow x {
					ans = Math.max(ans, pow);
				} ans = Math.max(ans, pow) ans Math.max(ans, pow) Math.max Math ans pow 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 scan = new Scanner(System.in);
	    int x = scan.nextInt();
	    scan.close();
	    int pow = 0;
		int ans = 1;
		for (int i = 1; i < x; i++) {
			for (int j = 2; j < x; j++) {
				pow = (int) Math.pow(i, j);
				if (pow <= x) {
					ans = Math.max(ans, pow);
				}
			}
		}
		System.out.println(ans);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	    int x = scan.nextInt();
	    scan.close();
	    int pow = 0;
		int ans = 1;
		for (int i = 1; i < x; i++) {
			for (int j = 2; j < x; j++) {
				pow = (int) Math.pow(i, j);
				if (pow <= x) {
					ans = Math.max(ans, pow);
				}
			}
		}
		System.out.println(ans);
	}

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

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
	    int x = scan.nextInt();
	    scan.close();
	    int pow = 0;
		int ans = 1;
		for (int i = 1; i < x; i++) {
			for (int j = 2; j < x; j++) {
				pow = (int) Math.pow(i, j);
				if (pow <= x) {
					ans = Math.max(ans, pow);
				}
			}
		}
		System.out.println(ans);
	}

}