import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int ans = 0;
		for(int i = 1; i <= x; i++) {
			int temp = 0;
			for(int j = 2; j <= 10; j++) {
				int judge = (int) Math.pow(i, j);
				if(judge > x) {
					break;
				}
				temp = judge;
			
			}
			ans = Math.max(temp, ans);
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int ans = 0;
		for(int i = 1; i <= x; i++) {
			int temp = 0;
			for(int j = 2; j <= 10; j++) {
				int judge = (int) Math.pow(i, j);
				if(judge > x) {
					break;
				}
				temp = judge;
			
			}
			ans = Math.max(temp, ans);
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int ans = 0;
		for(int i = 1; i <= x; i++) {
			int temp = 0;
			for(int j = 2; j <= 10; j++) {
				int judge = (int) Math.pow(i, j);
				if(judge > x) {
					break;
				}
				temp = judge;
			
			}
			ans = Math.max(temp, ans);
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int ans = 0;
		for(int i = 1; i <= x; i++) {
			int temp = 0;
			for(int j = 2; j <= 10; j++) {
				int judge = (int) Math.pow(i, j);
				if(judge > x) {
					break;
				}
				temp = judge;
			
			}
			ans = Math.max(temp, ans);
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int ans = 0; ans 0 for(int i = 1; i <= x; i++) {
			int temp = 0;
			for(int j = 2; j <= 10; j++) {
				int judge = (int) Math.pow(i, j);
				if(judge > x) {
					break;
				}
				temp = judge;
			
			}
			ans = Math.max(temp, ans);
		} int i = 1; int i = 1; i 1 i <= x i x i++ i++ i {
			int temp = 0;
			for(int j = 2; j <= 10; j++) {
				int judge = (int) Math.pow(i, j);
				if(judge > x) {
					break;
				}
				temp = judge;
			
			}
			ans = Math.max(temp, ans);
		} {
			int temp = 0;
			for(int j = 2; j <= 10; j++) {
				int judge = (int) Math.pow(i, j);
				if(judge > x) {
					break;
				}
				temp = judge;
			
			}
			ans = Math.max(temp, ans);
		} int temp = 0; temp 0 for(int j = 2; j <= 10; j++) {
				int judge = (int) Math.pow(i, j);
				if(judge > x) {
					break;
				}
				temp = judge;
			
			} int j = 2; int j = 2; j 2 j <= 10 j 10 j++ j++ j {
				int judge = (int) Math.pow(i, j);
				if(judge > x) {
					break;
				}
				temp = judge;
			
			} {
				int judge = (int) Math.pow(i, j);
				if(judge > x) {
					break;
				}
				temp = judge;
			
			} int judge = (int) Math.pow(i, j); judge (int) Math.pow(i, j) Math.pow Math i j if(judge > x) {
					break;
				} judge > x judge x {
					break;
				} break; temp = judge temp judge ans = Math.max(temp, ans) ans Math.max(temp, ans) Math.max Math temp ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int ans = 0;
		for(int i = 1; i <= x; i++) {
			int temp = 0;
			for(int j = 2; j <= 10; j++) {
				int judge = (int) Math.pow(i, j);
				if(judge > x) {
					break;
				}
				temp = judge;
			
			}
			ans = Math.max(temp, ans);
		}
		System.out.println(ans);
	}
} public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int ans = 0;
		for(int i = 1; i <= x; i++) {
			int temp = 0;
			for(int j = 2; j <= 10; j++) {
				int judge = (int) Math.pow(i, j);
				if(judge > x) {
					break;
				}
				temp = judge;
			
			}
			ans = Math.max(temp, ans);
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int ans = 0;
		for(int i = 1; i <= x; i++) {
			int temp = 0;
			for(int j = 2; j <= 10; j++) {
				int judge = (int) Math.pow(i, j);
				if(judge > x) {
					break;
				}
				temp = judge;
			
			}
			ans = Math.max(temp, ans);
		}
		System.out.println(ans);
	}
}