import java.util.Scanner;

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