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 = 1;
		for (int i = 2; i <= x; i++) {
			int temp = i*i;
			for (int j = 2; j <= x; j++) {
			
				if (temp > x) {
					break;
				}
				ans = Math.max(temp, ans);
				temp *= i;
			}
		}
		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 = 1;
		for (int i = 2; i <= x; i++) {
			int temp = i*i;
			for (int j = 2; j <= x; j++) {
			
				if (temp > x) {
					break;
				}
				ans = Math.max(temp, ans);
				temp *= i;
			}
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int ans = 1;
		for (int i = 2; i <= x; i++) {
			int temp = i*i;
			for (int j = 2; j <= x; j++) {
			
				if (temp > x) {
					break;
				}
				ans = Math.max(temp, ans);
				temp *= i;
			}
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int ans = 1;
		for (int i = 2; i <= x; i++) {
			int temp = i*i;
			for (int j = 2; j <= x; j++) {
			
				if (temp > x) {
					break;
				}
				ans = Math.max(temp, ans);
				temp *= i;
			}
		}
		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 = 1; ans 1 for (int i = 2; i <= x; i++) {
			int temp = i*i;
			for (int j = 2; j <= x; j++) {
			
				if (temp > x) {
					break;
				}
				ans = Math.max(temp, ans);
				temp *= i;
			}
		} int i = 2; int i = 2; i 2 i <= x i x i++ i++ i {
			int temp = i*i;
			for (int j = 2; j <= x; j++) {
			
				if (temp > x) {
					break;
				}
				ans = Math.max(temp, ans);
				temp *= i;
			}
		} {
			int temp = i*i;
			for (int j = 2; j <= x; j++) {
			
				if (temp > x) {
					break;
				}
				ans = Math.max(temp, ans);
				temp *= i;
			}
		} int temp = i*i; temp i*i i i for (int j = 2; j <= x; j++) {
			
				if (temp > x) {
					break;
				}
				ans = Math.max(temp, ans);
				temp *= i;
			} int j = 2; int j = 2; j 2 j <= x j x j++ j++ j {
			
				if (temp > x) {
					break;
				}
				ans = Math.max(temp, ans);
				temp *= i;
			} {
			
				if (temp > x) {
					break;
				}
				ans = Math.max(temp, ans);
				temp *= i;
			} if (temp > x) {
					break;
				} temp > x temp x {
					break;
				} break; ans = Math.max(temp, ans) ans Math.max(temp, ans) Math.max Math temp ans temp *= i temp i 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 = 1;
		for (int i = 2; i <= x; i++) {
			int temp = i*i;
			for (int j = 2; j <= x; j++) {
			
				if (temp > x) {
					break;
				}
				ans = Math.max(temp, ans);
				temp *= i;
			}
		}
		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 = 1;
		for (int i = 2; i <= x; i++) {
			int temp = i*i;
			for (int j = 2; j <= x; j++) {
			
				if (temp > x) {
					break;
				}
				ans = Math.max(temp, ans);
				temp *= i;
			}
		}
		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 = 1;
		for (int i = 2; i <= x; i++) {
			int temp = i*i;
			for (int j = 2; j <= x; j++) {
			
				if (temp > x) {
					break;
				}
				ans = Math.max(temp, ans);
				temp *= i;
			}
		}
		System.out.println(ans);
	}
}