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 >= 1; i--) {
			for (int j = 1; j < 32; j++) {
				for (int j2 = 2; j2 < 10; j2++) {
					int a = (int) Math.pow(j, j2);
					if (a == 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 >= 1; i--) {
			for (int j = 1; j < 32; j++) {
				for (int j2 = 2; j2 < 10; j2++) {
					int a = (int) Math.pow(j, j2);
					if (a == 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 >= 1; i--) {
			for (int j = 1; j < 32; j++) {
				for (int j2 = 2; j2 < 10; j2++) {
					int a = (int) Math.pow(j, j2);
					if (a == i) {
						System.out.println(i);
						return;
					}
				}
			}
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();

		for (int i = x; i >= 1; i--) {
			for (int j = 1; j < 32; j++) {
				for (int j2 = 2; j2 < 10; j2++) {
					int a = (int) Math.pow(j, j2);
					if (a == 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 >= 1; i--) {
			for (int j = 1; j < 32; j++) {
				for (int j2 = 2; j2 < 10; j2++) {
					int a = (int) Math.pow(j, j2);
					if (a == i) {
						System.out.println(i);
						return;
					}
				}
			}
		} int i = x; int i = x; i x i >= 1 i 1 i-- i-- i {
			for (int j = 1; j < 32; j++) {
				for (int j2 = 2; j2 < 10; j2++) {
					int a = (int) Math.pow(j, j2);
					if (a == i) {
						System.out.println(i);
						return;
					}
				}
			}
		} {
			for (int j = 1; j < 32; j++) {
				for (int j2 = 2; j2 < 10; j2++) {
					int a = (int) Math.pow(j, j2);
					if (a == i) {
						System.out.println(i);
						return;
					}
				}
			}
		} for (int j = 1; j < 32; j++) {
				for (int j2 = 2; j2 < 10; j2++) {
					int a = (int) Math.pow(j, j2);
					if (a == i) {
						System.out.println(i);
						return;
					}
				}
			} int j = 1; int j = 1; j 1 j < 32 j 32 j++ j++ j {
				for (int j2 = 2; j2 < 10; j2++) {
					int a = (int) Math.pow(j, j2);
					if (a == i) {
						System.out.println(i);
						return;
					}
				}
			} {
				for (int j2 = 2; j2 < 10; j2++) {
					int a = (int) Math.pow(j, j2);
					if (a == i) {
						System.out.println(i);
						return;
					}
				}
			} for (int j2 = 2; j2 < 10; j2++) {
					int a = (int) Math.pow(j, j2);
					if (a == i) {
						System.out.println(i);
						return;
					}
				} int j2 = 2; int j2 = 2; j2 2 j2 < 10 j2 10 j2++ j2++ j2 {
					int a = (int) Math.pow(j, j2);
					if (a == i) {
						System.out.println(i);
						return;
					}
				} {
					int a = (int) Math.pow(j, j2);
					if (a == i) {
						System.out.println(i);
						return;
					}
				} int a = (int) Math.pow(j, j2); a (int) Math.pow(j, j2) Math.pow Math j j2 if (a == i) {
						System.out.println(i);
						return;
					} a == i a 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 >= 1; i--) {
			for (int j = 1; j < 32; j++) {
				for (int j2 = 2; j2 < 10; j2++) {
					int a = (int) Math.pow(j, j2);
					if (a == 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 >= 1; i--) {
			for (int j = 1; j < 32; j++) {
				for (int j2 = 2; j2 < 10; j2++) {
					int a = (int) Math.pow(j, j2);
					if (a == 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 >= 1; i--) {
			for (int j = 1; j < 32; j++) {
				for (int j2 = 2; j2 < 10; j2++) {
					int a = (int) Math.pow(j, j2);
					if (a == i) {
						System.out.println(i);
						return;
					}
				}
			}
		}
	}
}
