import java.util.Scanner;

class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		int max = 1;

		for (int i = 1; i <= X; i++) {
			for (int j = 2; j <= X; j++) {
				double expo = Math.pow(i,  j);
				if (expo > X) {
					break;
				}

				if (max < expo) {
					max = (int)expo;
				}
				//System.out.println(i + "^" + j + "=" + (int)expo);
			}
		}
		System.out.println(max);
	}
} import java.util.Scanner; Scanner java.util class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		int max = 1;

		for (int i = 1; i <= X; i++) {
			for (int j = 2; j <= X; j++) {
				double expo = Math.pow(i,  j);
				if (expo > X) {
					break;
				}

				if (max < expo) {
					max = (int)expo;
				}
				//System.out.println(i + "^" + j + "=" + (int)expo);
			}
		}
		System.out.println(max);
	}
} Main public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		int max = 1;

		for (int i = 1; i <= X; i++) {
			for (int j = 2; j <= X; j++) {
				double expo = Math.pow(i,  j);
				if (expo > X) {
					break;
				}

				if (max < expo) {
					max = (int)expo;
				}
				//System.out.println(i + "^" + j + "=" + (int)expo);
			}
		}
		System.out.println(max);
	} main {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		int max = 1;

		for (int i = 1; i <= X; i++) {
			for (int j = 2; j <= X; j++) {
				double expo = Math.pow(i,  j);
				if (expo > X) {
					break;
				}

				if (max < expo) {
					max = (int)expo;
				}
				//System.out.println(i + "^" + j + "=" + (int)expo);
			}
		}
		System.out.println(max);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int X = scanner.nextInt(); X scanner.nextInt() scanner.nextInt scanner int max = 1; max 1 for (int i = 1; i <= X; i++) {
			for (int j = 2; j <= X; j++) {
				double expo = Math.pow(i,  j);
				if (expo > X) {
					break;
				}

				if (max < expo) {
					max = (int)expo;
				}
				//System.out.println(i + "^" + j + "=" + (int)expo);
			}
		} int i = 1; int i = 1; i 1 i <= X i X i++ i++ i {
			for (int j = 2; j <= X; j++) {
				double expo = Math.pow(i,  j);
				if (expo > X) {
					break;
				}

				if (max < expo) {
					max = (int)expo;
				}
				//System.out.println(i + "^" + j + "=" + (int)expo);
			}
		} {
			for (int j = 2; j <= X; j++) {
				double expo = Math.pow(i,  j);
				if (expo > X) {
					break;
				}

				if (max < expo) {
					max = (int)expo;
				}
				//System.out.println(i + "^" + j + "=" + (int)expo);
			}
		} for (int j = 2; j <= X; j++) {
				double expo = Math.pow(i,  j);
				if (expo > X) {
					break;
				}

				if (max < expo) {
					max = (int)expo;
				}
				//System.out.println(i + "^" + j + "=" + (int)expo);
			} int j = 2; int j = 2; j 2 j <= X j X j++ j++ j {
				double expo = Math.pow(i,  j);
				if (expo > X) {
					break;
				}

				if (max < expo) {
					max = (int)expo;
				}
				//System.out.println(i + "^" + j + "=" + (int)expo);
			} {
				double expo = Math.pow(i,  j);
				if (expo > X) {
					break;
				}

				if (max < expo) {
					max = (int)expo;
				}
				//System.out.println(i + "^" + j + "=" + (int)expo);
			} double expo = Math.pow(i,  j); expo Math.pow(i,  j) Math.pow Math i j if (expo > X) {
					break;
				} expo > X expo X {
					break;
				} break; if (max < expo) {
					max = (int)expo;
				} max < expo max expo {
					max = (int)expo;
				} max = (int)expo max (int)expo System.out.println(max) System.out.println System.out System System.out max String[] args args
import java.util.Scanner;

class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		int max = 1;

		for (int i = 1; i <= X; i++) {
			for (int j = 2; j <= X; j++) {
				double expo = Math.pow(i,  j);
				if (expo > X) {
					break;
				}

				if (max < expo) {
					max = (int)expo;
				}
				//System.out.println(i + "^" + j + "=" + (int)expo);
			}
		}
		System.out.println(max);
	}
}
