import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		boolean[] expo = new boolean[X + 1];
		expo[1] = true;
		for (int i = 2; i <= X; i++) {
			int v = i * i;
			while (v <= X) {
				expo[v] = true;
				v *= i;
			}
		}
		for (int i = X; i >= 1; i--) {
			if (expo[i]) {
				System.out.println(i);
				break;
			}
		}
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		boolean[] expo = new boolean[X + 1];
		expo[1] = true;
		for (int i = 2; i <= X; i++) {
			int v = i * i;
			while (v <= X) {
				expo[v] = true;
				v *= i;
			}
		}
		for (int i = X; i >= 1; i--) {
			if (expo[i]) {
				System.out.println(i);
				break;
			}
		}
		sc.close();
	}
} Main public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		boolean[] expo = new boolean[X + 1];
		expo[1] = true;
		for (int i = 2; i <= X; i++) {
			int v = i * i;
			while (v <= X) {
				expo[v] = true;
				v *= i;
			}
		}
		for (int i = X; i >= 1; i--) {
			if (expo[i]) {
				System.out.println(i);
				break;
			}
		}
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		boolean[] expo = new boolean[X + 1];
		expo[1] = true;
		for (int i = 2; i <= X; i++) {
			int v = i * i;
			while (v <= X) {
				expo[v] = true;
				v *= i;
			}
		}
		for (int i = X; i >= 1; i--) {
			if (expo[i]) {
				System.out.println(i);
				break;
			}
		}
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc boolean[] expo = new boolean[X + 1]; expo new boolean[X + 1] X + 1 X 1 expo[1] = true expo[1] expo 1 true for (int i = 2; i <= X; i++) {
			int v = i * i;
			while (v <= X) {
				expo[v] = true;
				v *= i;
			}
		} int i = 2; int i = 2; i 2 i <= X i X i++ i++ i {
			int v = i * i;
			while (v <= X) {
				expo[v] = true;
				v *= i;
			}
		} {
			int v = i * i;
			while (v <= X) {
				expo[v] = true;
				v *= i;
			}
		} int v = i * i; v i * i i i while (v <= X) {
				expo[v] = true;
				v *= i;
			} v <= X v X {
				expo[v] = true;
				v *= i;
			} expo[v] = true expo[v] expo v true v *= i v i for (int i = X; i >= 1; i--) {
			if (expo[i]) {
				System.out.println(i);
				break;
			}
		} int i = X; int i = X; i X i >= 1 i 1 i-- i-- i {
			if (expo[i]) {
				System.out.println(i);
				break;
			}
		} {
			if (expo[i]) {
				System.out.println(i);
				break;
			}
		} if (expo[i]) {
				System.out.println(i);
				break;
			} expo[i] expo i {
				System.out.println(i);
				break;
			} System.out.println(i) System.out.println System.out System System.out i break; sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		boolean[] expo = new boolean[X + 1];
		expo[1] = true;
		for (int i = 2; i <= X; i++) {
			int v = i * i;
			while (v <= X) {
				expo[v] = true;
				v *= i;
			}
		}
		for (int i = X; i >= 1; i--) {
			if (expo[i]) {
				System.out.println(i);
				break;
			}
		}
		sc.close();
	}
} public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		boolean[] expo = new boolean[X + 1];
		expo[1] = true;
		for (int i = 2; i <= X; i++) {
			int v = i * i;
			while (v <= X) {
				expo[v] = true;
				v *= i;
			}
		}
		for (int i = X; i >= 1; i--) {
			if (expo[i]) {
				System.out.println(i);
				break;
			}
		}
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		boolean[] expo = new boolean[X + 1];
		expo[1] = true;
		for (int i = 2; i <= X; i++) {
			int v = i * i;
			while (v <= X) {
				expo[v] = true;
				v *= i;
			}
		}
		for (int i = X; i >= 1; i--) {
			if (expo[i]) {
				System.out.println(i);
				break;
			}
		}
		sc.close();
	}
}