import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		Set<Integer> s = createPowSet();
		for (int i = X; i >= 0; i--) {
			if (s.contains(i)) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(1);
	}

	private static Set<Integer> createPowSet() {
		Set<Integer> s = new HashSet<>();
		for (int i = 2; i <= 1000; i++) {
			for (int j = 2; j <= 1000; j++) {
				int num = (int)Math.pow(i, j);
				if (num > 1000) {
					if (j == 2) {
						return s;
					} else {
						break;
					}
				}
				s.add(num);
			}
		}
		return s;
	}
} import java.util.Scanner; Scanner java.util import java.util.Set; Set java.util import java.util.HashSet; HashSet java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		Set<Integer> s = createPowSet();
		for (int i = X; i >= 0; i--) {
			if (s.contains(i)) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(1);
	}

	private static Set<Integer> createPowSet() {
		Set<Integer> s = new HashSet<>();
		for (int i = 2; i <= 1000; i++) {
			for (int j = 2; j <= 1000; j++) {
				int num = (int)Math.pow(i, j);
				if (num > 1000) {
					if (j == 2) {
						return s;
					} else {
						break;
					}
				}
				s.add(num);
			}
		}
		return s;
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		Set<Integer> s = createPowSet();
		for (int i = X; i >= 0; i--) {
			if (s.contains(i)) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(1);
	} main {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		Set<Integer> s = createPowSet();
		for (int i = X; i >= 0; i--) {
			if (s.contains(i)) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(1);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc Set<Integer> s = createPowSet(); s createPowSet() createPowSet for (int i = X; i >= 0; i--) {
			if (s.contains(i)) {
				System.out.println(i);
				return;
			}
		} int i = X; int i = X; i X i >= 0 i 0 i-- i-- i {
			if (s.contains(i)) {
				System.out.println(i);
				return;
			}
		} {
			if (s.contains(i)) {
				System.out.println(i);
				return;
			}
		} if (s.contains(i)) {
				System.out.println(i);
				return;
			} s.contains(i) s.contains s i {
				System.out.println(i);
				return;
			} System.out.println(i) System.out.println System.out System System.out i return; System.out.println(1) System.out.println System.out System System.out 1 String[] args args private static Set<Integer> createPowSet() {
		Set<Integer> s = new HashSet<>();
		for (int i = 2; i <= 1000; i++) {
			for (int j = 2; j <= 1000; j++) {
				int num = (int)Math.pow(i, j);
				if (num > 1000) {
					if (j == 2) {
						return s;
					} else {
						break;
					}
				}
				s.add(num);
			}
		}
		return s;
	} createPowSet {
		Set<Integer> s = new HashSet<>();
		for (int i = 2; i <= 1000; i++) {
			for (int j = 2; j <= 1000; j++) {
				int num = (int)Math.pow(i, j);
				if (num > 1000) {
					if (j == 2) {
						return s;
					} else {
						break;
					}
				}
				s.add(num);
			}
		}
		return s;
	} Set<Integer> s = new HashSet<>(); s new HashSet<>() for (int i = 2; i <= 1000; i++) {
			for (int j = 2; j <= 1000; j++) {
				int num = (int)Math.pow(i, j);
				if (num > 1000) {
					if (j == 2) {
						return s;
					} else {
						break;
					}
				}
				s.add(num);
			}
		} int i = 2; int i = 2; i 2 i <= 1000 i 1000 i++ i++ i {
			for (int j = 2; j <= 1000; j++) {
				int num = (int)Math.pow(i, j);
				if (num > 1000) {
					if (j == 2) {
						return s;
					} else {
						break;
					}
				}
				s.add(num);
			}
		} {
			for (int j = 2; j <= 1000; j++) {
				int num = (int)Math.pow(i, j);
				if (num > 1000) {
					if (j == 2) {
						return s;
					} else {
						break;
					}
				}
				s.add(num);
			}
		} for (int j = 2; j <= 1000; j++) {
				int num = (int)Math.pow(i, j);
				if (num > 1000) {
					if (j == 2) {
						return s;
					} else {
						break;
					}
				}
				s.add(num);
			} int j = 2; int j = 2; j 2 j <= 1000 j 1000 j++ j++ j {
				int num = (int)Math.pow(i, j);
				if (num > 1000) {
					if (j == 2) {
						return s;
					} else {
						break;
					}
				}
				s.add(num);
			} {
				int num = (int)Math.pow(i, j);
				if (num > 1000) {
					if (j == 2) {
						return s;
					} else {
						break;
					}
				}
				s.add(num);
			} int num = (int)Math.pow(i, j); num (int)Math.pow(i, j) Math.pow Math i j if (num > 1000) {
					if (j == 2) {
						return s;
					} else {
						break;
					}
				} num > 1000 num 1000 {
					if (j == 2) {
						return s;
					} else {
						break;
					}
				} if (j == 2) {
						return s;
					} else {
						break;
					} j == 2 j 2 {
						return s;
					} return s; s {
						break;
					} break; s.add(num) s.add s num return s; s public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		Set<Integer> s = createPowSet();
		for (int i = X; i >= 0; i--) {
			if (s.contains(i)) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(1);
	}

	private static Set<Integer> createPowSet() {
		Set<Integer> s = new HashSet<>();
		for (int i = 2; i <= 1000; i++) {
			for (int j = 2; j <= 1000; j++) {
				int num = (int)Math.pow(i, j);
				if (num > 1000) {
					if (j == 2) {
						return s;
					} else {
						break;
					}
				}
				s.add(num);
			}
		}
		return s;
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		Set<Integer> s = createPowSet();
		for (int i = X; i >= 0; i--) {
			if (s.contains(i)) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(1);
	}

	private static Set<Integer> createPowSet() {
		Set<Integer> s = new HashSet<>();
		for (int i = 2; i <= 1000; i++) {
			for (int j = 2; j <= 1000; j++) {
				int num = (int)Math.pow(i, j);
				if (num > 1000) {
					if (j == 2) {
						return s;
					} else {
						break;
					}
				}
				s.add(num);
			}
		}
		return s;
	}
} Main
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		Set<Integer> s = createPowSet();
		for (int i = X; i >= 0; i--) {
			if (s.contains(i)) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(1);
	}

	private static Set<Integer> createPowSet() {
		Set<Integer> s = new HashSet<>();
		for (int i = 2; i <= 1000; i++) {
			for (int j = 2; j <= 1000; j++) {
				int num = (int)Math.pow(i, j);
				if (num > 1000) {
					if (j == 2) {
						return s;
					} else {
						break;
					}
				}
				s.add(num);
			}
		}
		return s;
	}
}