import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner sn = new Scanner(System.in)) {
			int x = sn.nextInt();
			double max = 1;
			double tmp = 0;
			LAB:for (int i = 2; i < x; i++) {
				int j = 2;
				while (true) {
					tmp = Math.pow(i, j);
					if (tmp <= x) {
						if (max <= tmp) {
							max = tmp;
						}
						j++;
					} else {
						continue LAB;
					}
				}
			}
			System.out.println((int)max);
		}
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		try(Scanner sn = new Scanner(System.in)) {
			int x = sn.nextInt();
			double max = 1;
			double tmp = 0;
			LAB:for (int i = 2; i < x; i++) {
				int j = 2;
				while (true) {
					tmp = Math.pow(i, j);
					if (tmp <= x) {
						if (max <= tmp) {
							max = tmp;
						}
						j++;
					} else {
						continue LAB;
					}
				}
			}
			System.out.println((int)max);
		}
	}

} Main public static void main(String[] args) {
		try(Scanner sn = new Scanner(System.in)) {
			int x = sn.nextInt();
			double max = 1;
			double tmp = 0;
			LAB:for (int i = 2; i < x; i++) {
				int j = 2;
				while (true) {
					tmp = Math.pow(i, j);
					if (tmp <= x) {
						if (max <= tmp) {
							max = tmp;
						}
						j++;
					} else {
						continue LAB;
					}
				}
			}
			System.out.println((int)max);
		}
	} main {
		try(Scanner sn = new Scanner(System.in)) {
			int x = sn.nextInt();
			double max = 1;
			double tmp = 0;
			LAB:for (int i = 2; i < x; i++) {
				int j = 2;
				while (true) {
					tmp = Math.pow(i, j);
					if (tmp <= x) {
						if (max <= tmp) {
							max = tmp;
						}
						j++;
					} else {
						continue LAB;
					}
				}
			}
			System.out.println((int)max);
		}
	} try(Scanner sn = new Scanner(System.in)) {
			int x = sn.nextInt();
			double max = 1;
			double tmp = 0;
			LAB:for (int i = 2; i < x; i++) {
				int j = 2;
				while (true) {
					tmp = Math.pow(i, j);
					if (tmp <= x) {
						if (max <= tmp) {
							max = tmp;
						}
						j++;
					} else {
						continue LAB;
					}
				}
			}
			System.out.println((int)max);
		} {
			int x = sn.nextInt();
			double max = 1;
			double tmp = 0;
			LAB:for (int i = 2; i < x; i++) {
				int j = 2;
				while (true) {
					tmp = Math.pow(i, j);
					if (tmp <= x) {
						if (max <= tmp) {
							max = tmp;
						}
						j++;
					} else {
						continue LAB;
					}
				}
			}
			System.out.println((int)max);
		} Scanner sn = new Scanner(System.in) Scanner sn = new Scanner(System.in) new Scanner(System.in) int x = sn.nextInt(); x sn.nextInt() sn.nextInt sn double max = 1; max 1 double tmp = 0; tmp 0 System.out.println((int)max) System.out.println System.out System System.out (int)max String[] args args public class Main {

	public static void main(String[] args) {
		try(Scanner sn = new Scanner(System.in)) {
			int x = sn.nextInt();
			double max = 1;
			double tmp = 0;
			LAB:for (int i = 2; i < x; i++) {
				int j = 2;
				while (true) {
					tmp = Math.pow(i, j);
					if (tmp <= x) {
						if (max <= tmp) {
							max = tmp;
						}
						j++;
					} else {
						continue LAB;
					}
				}
			}
			System.out.println((int)max);
		}
	}

} public class Main {

	public static void main(String[] args) {
		try(Scanner sn = new Scanner(System.in)) {
			int x = sn.nextInt();
			double max = 1;
			double tmp = 0;
			LAB:for (int i = 2; i < x; i++) {
				int j = 2;
				while (true) {
					tmp = Math.pow(i, j);
					if (tmp <= x) {
						if (max <= tmp) {
							max = tmp;
						}
						j++;
					} else {
						continue LAB;
					}
				}
			}
			System.out.println((int)max);
		}
	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner sn = new Scanner(System.in)) {
			int x = sn.nextInt();
			double max = 1;
			double tmp = 0;
			LAB:for (int i = 2; i < x; i++) {
				int j = 2;
				while (true) {
					tmp = Math.pow(i, j);
					if (tmp <= x) {
						if (max <= tmp) {
							max = tmp;
						}
						j++;
					} else {
						continue LAB;
					}
				}
			}
			System.out.println((int)max);
		}
	}

}
