import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int result = 0;
		int count = 1;
		for(int i = 1;i <= X;i++) {
			for(int j = 2;;j++) {
				if(i == 1) {
					result = 1;
					break;
				}
				if((int)Math.pow(i,j) > X) {
					break;
				}else {
					if((int)Math.pow(i,j) >= result) {
						result = (int)Math.pow(i,j);
					}
				}
				count = (int)Math.pow(i,j);
			}
		}
		System.out.println(result);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int result = 0;
		int count = 1;
		for(int i = 1;i <= X;i++) {
			for(int j = 2;;j++) {
				if(i == 1) {
					result = 1;
					break;
				}
				if((int)Math.pow(i,j) > X) {
					break;
				}else {
					if((int)Math.pow(i,j) >= result) {
						result = (int)Math.pow(i,j);
					}
				}
				count = (int)Math.pow(i,j);
			}
		}
		System.out.println(result);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int result = 0;
		int count = 1;
		for(int i = 1;i <= X;i++) {
			for(int j = 2;;j++) {
				if(i == 1) {
					result = 1;
					break;
				}
				if((int)Math.pow(i,j) > X) {
					break;
				}else {
					if((int)Math.pow(i,j) >= result) {
						result = (int)Math.pow(i,j);
					}
				}
				count = (int)Math.pow(i,j);
			}
		}
		System.out.println(result);
	} main {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int result = 0;
		int count = 1;
		for(int i = 1;i <= X;i++) {
			for(int j = 2;;j++) {
				if(i == 1) {
					result = 1;
					break;
				}
				if((int)Math.pow(i,j) > X) {
					break;
				}else {
					if((int)Math.pow(i,j) >= result) {
						result = (int)Math.pow(i,j);
					}
				}
				count = (int)Math.pow(i,j);
			}
		}
		System.out.println(result);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int X = scan.nextInt(); X scan.nextInt() scan.nextInt scan int result = 0; result 0 int count = 1; count 1 for(int i = 1;i <= X;i++) {
			for(int j = 2;;j++) {
				if(i == 1) {
					result = 1;
					break;
				}
				if((int)Math.pow(i,j) > X) {
					break;
				}else {
					if((int)Math.pow(i,j) >= result) {
						result = (int)Math.pow(i,j);
					}
				}
				count = (int)Math.pow(i,j);
			}
		} int i = 1; int i = 1; i 1 i <= X i X i++ i++ i {
			for(int j = 2;;j++) {
				if(i == 1) {
					result = 1;
					break;
				}
				if((int)Math.pow(i,j) > X) {
					break;
				}else {
					if((int)Math.pow(i,j) >= result) {
						result = (int)Math.pow(i,j);
					}
				}
				count = (int)Math.pow(i,j);
			}
		} {
			for(int j = 2;;j++) {
				if(i == 1) {
					result = 1;
					break;
				}
				if((int)Math.pow(i,j) > X) {
					break;
				}else {
					if((int)Math.pow(i,j) >= result) {
						result = (int)Math.pow(i,j);
					}
				}
				count = (int)Math.pow(i,j);
			}
		} for(int j = 2;;j++) {
				if(i == 1) {
					result = 1;
					break;
				}
				if((int)Math.pow(i,j) > X) {
					break;
				}else {
					if((int)Math.pow(i,j) >= result) {
						result = (int)Math.pow(i,j);
					}
				}
				count = (int)Math.pow(i,j);
			} int j = 2; int j = 2; j 2 j++ j++ j {
				if(i == 1) {
					result = 1;
					break;
				}
				if((int)Math.pow(i,j) > X) {
					break;
				}else {
					if((int)Math.pow(i,j) >= result) {
						result = (int)Math.pow(i,j);
					}
				}
				count = (int)Math.pow(i,j);
			} {
				if(i == 1) {
					result = 1;
					break;
				}
				if((int)Math.pow(i,j) > X) {
					break;
				}else {
					if((int)Math.pow(i,j) >= result) {
						result = (int)Math.pow(i,j);
					}
				}
				count = (int)Math.pow(i,j);
			} if(i == 1) {
					result = 1;
					break;
				} i == 1 i 1 {
					result = 1;
					break;
				} result = 1 result 1 break; if((int)Math.pow(i,j) > X) {
					break;
				}else {
					if((int)Math.pow(i,j) >= result) {
						result = (int)Math.pow(i,j);
					}
				} (int)Math.pow(i,j) > X (int)Math.pow(i,j) Math.pow Math i j X {
					break;
				} break; {
					if((int)Math.pow(i,j) >= result) {
						result = (int)Math.pow(i,j);
					}
				} if((int)Math.pow(i,j) >= result) {
						result = (int)Math.pow(i,j);
					} (int)Math.pow(i,j) >= result (int)Math.pow(i,j) Math.pow Math i j result {
						result = (int)Math.pow(i,j);
					} result = (int)Math.pow(i,j) result (int)Math.pow(i,j) Math.pow Math i j count = (int)Math.pow(i,j) count (int)Math.pow(i,j) Math.pow Math i j System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int result = 0;
		int count = 1;
		for(int i = 1;i <= X;i++) {
			for(int j = 2;;j++) {
				if(i == 1) {
					result = 1;
					break;
				}
				if((int)Math.pow(i,j) > X) {
					break;
				}else {
					if((int)Math.pow(i,j) >= result) {
						result = (int)Math.pow(i,j);
					}
				}
				count = (int)Math.pow(i,j);
			}
		}
		System.out.println(result);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int result = 0;
		int count = 1;
		for(int i = 1;i <= X;i++) {
			for(int j = 2;;j++) {
				if(i == 1) {
					result = 1;
					break;
				}
				if((int)Math.pow(i,j) > X) {
					break;
				}else {
					if((int)Math.pow(i,j) >= result) {
						result = (int)Math.pow(i,j);
					}
				}
				count = (int)Math.pow(i,j);
			}
		}
		System.out.println(result);
	}
} Main
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int result = 0;
		int count = 1;
		for(int i = 1;i <= X;i++) {
			for(int j = 2;;j++) {
				if(i == 1) {
					result = 1;
					break;
				}
				if((int)Math.pow(i,j) > X) {
					break;
				}else {
					if((int)Math.pow(i,j) >= result) {
						result = (int)Math.pow(i,j);
					}
				}
				count = (int)Math.pow(i,j);
			}
		}
		System.out.println(result);
	}
}