import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x <= 3) {
			System.out.println(1);
			return;
		}
		outside: for(int i = x; ; i--) {
			for(int j = 2; j * j <= i; j++) {
				for(int k = 2; Math.pow(j, k) <= i; k++) {
					if(Math.pow(j, k) == i) {
						System.out.println(i);
						break outside;
					}
				}
			}
		}
	}
} import java.util.*; util.* java public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x <= 3) {
			System.out.println(1);
			return;
		}
		outside: for(int i = x; ; i--) {
			for(int j = 2; j * j <= i; j++) {
				for(int k = 2; Math.pow(j, k) <= i; k++) {
					if(Math.pow(j, k) == i) {
						System.out.println(i);
						break outside;
					}
				}
			}
		}
	}
} Main public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x <= 3) {
			System.out.println(1);
			return;
		}
		outside: for(int i = x; ; i--) {
			for(int j = 2; j * j <= i; j++) {
				for(int k = 2; Math.pow(j, k) <= i; k++) {
					if(Math.pow(j, k) == i) {
						System.out.println(i);
						break outside;
					}
				}
			}
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x <= 3) {
			System.out.println(1);
			return;
		}
		outside: for(int i = x; ; i--) {
			for(int j = 2; j * j <= i; j++) {
				for(int k = 2; Math.pow(j, k) <= i; k++) {
					if(Math.pow(j, k) == i) {
						System.out.println(i);
						break outside;
					}
				}
			}
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc if(x <= 3) {
			System.out.println(1);
			return;
		} x <= 3 x 3 {
			System.out.println(1);
			return;
		} System.out.println(1) System.out.println System.out System System.out 1 return; String args[] args public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x <= 3) {
			System.out.println(1);
			return;
		}
		outside: for(int i = x; ; i--) {
			for(int j = 2; j * j <= i; j++) {
				for(int k = 2; Math.pow(j, k) <= i; k++) {
					if(Math.pow(j, k) == i) {
						System.out.println(i);
						break outside;
					}
				}
			}
		}
	}
} public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x <= 3) {
			System.out.println(1);
			return;
		}
		outside: for(int i = x; ; i--) {
			for(int j = 2; j * j <= i; j++) {
				for(int k = 2; Math.pow(j, k) <= i; k++) {
					if(Math.pow(j, k) == i) {
						System.out.println(i);
						break outside;
					}
				}
			}
		}
	}
} Main
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if(x <= 3) {
			System.out.println(1);
			return;
		}
		outside: for(int i = x; ; i--) {
			for(int j = 2; j * j <= i; j++) {
				for(int k = 2; Math.pow(j, k) <= i; k++) {
					if(Math.pow(j, k) == i) {
						System.out.println(i);
						break outside;
					}
				}
			}
		}
	}
}