import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();

		for (int i = x; i > 0; i--) {
			for (int b = 1; b < 32; b++) {
				for (int p = 2; p < 10; p++) {
					if ((int) Math.pow(b, p) == i) {
						System.out.println(i);
						return;
					}
				}
			}
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();

		for (int i = x; i > 0; i--) {
			for (int b = 1; b < 32; b++) {
				for (int p = 2; p < 10; p++) {
					if ((int) Math.pow(b, p) == i) {
						System.out.println(i);
						return;
					}
				}
			}
		}
	}
} Main public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();

		for (int i = x; i > 0; i--) {
			for (int b = 1; b < 32; b++) {
				for (int p = 2; p < 10; p++) {
					if ((int) Math.pow(b, p) == i) {
						System.out.println(i);
						return;
					}
				}
			}
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();

		for (int i = x; i > 0; i--) {
			for (int b = 1; b < 32; b++) {
				for (int p = 2; p < 10; p++) {
					if ((int) Math.pow(b, p) == i) {
						System.out.println(i);
						return;
					}
				}
			}
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc sc.close() sc.close sc for (int i = x; i > 0; i--) {
			for (int b = 1; b < 32; b++) {
				for (int p = 2; p < 10; p++) {
					if ((int) Math.pow(b, p) == i) {
						System.out.println(i);
						return;
					}
				}
			}
		} int i = x; int i = x; i x i > 0 i 0 i-- i-- i {
			for (int b = 1; b < 32; b++) {
				for (int p = 2; p < 10; p++) {
					if ((int) Math.pow(b, p) == i) {
						System.out.println(i);
						return;
					}
				}
			}
		} {
			for (int b = 1; b < 32; b++) {
				for (int p = 2; p < 10; p++) {
					if ((int) Math.pow(b, p) == i) {
						System.out.println(i);
						return;
					}
				}
			}
		} for (int b = 1; b < 32; b++) {
				for (int p = 2; p < 10; p++) {
					if ((int) Math.pow(b, p) == i) {
						System.out.println(i);
						return;
					}
				}
			} int b = 1; int b = 1; b 1 b < 32 b 32 b++ b++ b {
				for (int p = 2; p < 10; p++) {
					if ((int) Math.pow(b, p) == i) {
						System.out.println(i);
						return;
					}
				}
			} {
				for (int p = 2; p < 10; p++) {
					if ((int) Math.pow(b, p) == i) {
						System.out.println(i);
						return;
					}
				}
			} for (int p = 2; p < 10; p++) {
					if ((int) Math.pow(b, p) == i) {
						System.out.println(i);
						return;
					}
				} int p = 2; int p = 2; p 2 p < 10 p 10 p++ p++ p {
					if ((int) Math.pow(b, p) == i) {
						System.out.println(i);
						return;
					}
				} {
					if ((int) Math.pow(b, p) == i) {
						System.out.println(i);
						return;
					}
				} if ((int) Math.pow(b, p) == i) {
						System.out.println(i);
						return;
					} (int) Math.pow(b, p) == i (int) Math.pow(b, p) Math.pow Math b p i {
						System.out.println(i);
						return;
					} System.out.println(i) System.out.println System.out System System.out i return; String[] args args public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();

		for (int i = x; i > 0; i--) {
			for (int b = 1; b < 32; b++) {
				for (int p = 2; p < 10; p++) {
					if ((int) Math.pow(b, p) == i) {
						System.out.println(i);
						return;
					}
				}
			}
		}
	}
} public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();

		for (int i = x; i > 0; i--) {
			for (int b = 1; b < 32; b++) {
				for (int p = 2; p < 10; p++) {
					if ((int) Math.pow(b, p) == i) {
						System.out.println(i);
						return;
					}
				}
			}
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();

		for (int i = x; i > 0; i--) {
			for (int b = 1; b < 32; b++) {
				for (int p = 2; p < 10; p++) {
					if ((int) Math.pow(b, p) == i) {
						System.out.println(i);
						return;
					}
				}
			}
		}
	}
}
