import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if (x <= 3) {
			System.out.println(1);
			sc.close();
			return;
		}

		int sqrt = (int) Math.sqrt(x);
		int maxp = 2;
		double maxans = 1;
		while (true) {
			if (Math.pow(2, maxp) < x) {
				maxp++;
			} else {
				maxp--;
				maxans = Math.pow(2, maxp);
				break;
			}
		}
		for (int i = 3; i <= sqrt; i++) {
			while (Math.pow(i, maxp) > x) {
				maxp--;
			}
			if (Math.pow(i, maxp) > maxans) {
				maxans = Math.pow(i, maxp);
			}
		}
		System.out.println((int) maxans);

		sc.close();
	}
} 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();
		if (x <= 3) {
			System.out.println(1);
			sc.close();
			return;
		}

		int sqrt = (int) Math.sqrt(x);
		int maxp = 2;
		double maxans = 1;
		while (true) {
			if (Math.pow(2, maxp) < x) {
				maxp++;
			} else {
				maxp--;
				maxans = Math.pow(2, maxp);
				break;
			}
		}
		for (int i = 3; i <= sqrt; i++) {
			while (Math.pow(i, maxp) > x) {
				maxp--;
			}
			if (Math.pow(i, maxp) > maxans) {
				maxans = Math.pow(i, maxp);
			}
		}
		System.out.println((int) maxans);

		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if (x <= 3) {
			System.out.println(1);
			sc.close();
			return;
		}

		int sqrt = (int) Math.sqrt(x);
		int maxp = 2;
		double maxans = 1;
		while (true) {
			if (Math.pow(2, maxp) < x) {
				maxp++;
			} else {
				maxp--;
				maxans = Math.pow(2, maxp);
				break;
			}
		}
		for (int i = 3; i <= sqrt; i++) {
			while (Math.pow(i, maxp) > x) {
				maxp--;
			}
			if (Math.pow(i, maxp) > maxans) {
				maxans = Math.pow(i, maxp);
			}
		}
		System.out.println((int) maxans);

		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if (x <= 3) {
			System.out.println(1);
			sc.close();
			return;
		}

		int sqrt = (int) Math.sqrt(x);
		int maxp = 2;
		double maxans = 1;
		while (true) {
			if (Math.pow(2, maxp) < x) {
				maxp++;
			} else {
				maxp--;
				maxans = Math.pow(2, maxp);
				break;
			}
		}
		for (int i = 3; i <= sqrt; i++) {
			while (Math.pow(i, maxp) > x) {
				maxp--;
			}
			if (Math.pow(i, maxp) > maxans) {
				maxans = Math.pow(i, maxp);
			}
		}
		System.out.println((int) maxans);

		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc if (x <= 3) {
			System.out.println(1);
			sc.close();
			return;
		} x <= 3 x 3 {
			System.out.println(1);
			sc.close();
			return;
		} System.out.println(1) System.out.println System.out System System.out 1 sc.close() sc.close sc return; int sqrt = (int) Math.sqrt(x); sqrt (int) Math.sqrt(x) Math.sqrt Math x int maxp = 2; maxp 2 double maxans = 1; maxans 1 while (true) {
			if (Math.pow(2, maxp) < x) {
				maxp++;
			} else {
				maxp--;
				maxans = Math.pow(2, maxp);
				break;
			}
		} true {
			if (Math.pow(2, maxp) < x) {
				maxp++;
			} else {
				maxp--;
				maxans = Math.pow(2, maxp);
				break;
			}
		} if (Math.pow(2, maxp) < x) {
				maxp++;
			} else {
				maxp--;
				maxans = Math.pow(2, maxp);
				break;
			} Math.pow(2, maxp) < x Math.pow(2, maxp) Math.pow Math 2 maxp x {
				maxp++;
			} maxp++ maxp {
				maxp--;
				maxans = Math.pow(2, maxp);
				break;
			} maxp-- maxp maxans = Math.pow(2, maxp) maxans Math.pow(2, maxp) Math.pow Math 2 maxp break; for (int i = 3; i <= sqrt; i++) {
			while (Math.pow(i, maxp) > x) {
				maxp--;
			}
			if (Math.pow(i, maxp) > maxans) {
				maxans = Math.pow(i, maxp);
			}
		} int i = 3; int i = 3; i 3 i <= sqrt i sqrt i++ i++ i {
			while (Math.pow(i, maxp) > x) {
				maxp--;
			}
			if (Math.pow(i, maxp) > maxans) {
				maxans = Math.pow(i, maxp);
			}
		} {
			while (Math.pow(i, maxp) > x) {
				maxp--;
			}
			if (Math.pow(i, maxp) > maxans) {
				maxans = Math.pow(i, maxp);
			}
		} while (Math.pow(i, maxp) > x) {
				maxp--;
			} Math.pow(i, maxp) > x Math.pow(i, maxp) Math.pow Math i maxp x {
				maxp--;
			} maxp-- maxp if (Math.pow(i, maxp) > maxans) {
				maxans = Math.pow(i, maxp);
			} Math.pow(i, maxp) > maxans Math.pow(i, maxp) Math.pow Math i maxp maxans {
				maxans = Math.pow(i, maxp);
			} maxans = Math.pow(i, maxp) maxans Math.pow(i, maxp) Math.pow Math i maxp System.out.println((int) maxans) System.out.println System.out System System.out (int) maxans sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if (x <= 3) {
			System.out.println(1);
			sc.close();
			return;
		}

		int sqrt = (int) Math.sqrt(x);
		int maxp = 2;
		double maxans = 1;
		while (true) {
			if (Math.pow(2, maxp) < x) {
				maxp++;
			} else {
				maxp--;
				maxans = Math.pow(2, maxp);
				break;
			}
		}
		for (int i = 3; i <= sqrt; i++) {
			while (Math.pow(i, maxp) > x) {
				maxp--;
			}
			if (Math.pow(i, maxp) > maxans) {
				maxans = Math.pow(i, maxp);
			}
		}
		System.out.println((int) maxans);

		sc.close();
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if (x <= 3) {
			System.out.println(1);
			sc.close();
			return;
		}

		int sqrt = (int) Math.sqrt(x);
		int maxp = 2;
		double maxans = 1;
		while (true) {
			if (Math.pow(2, maxp) < x) {
				maxp++;
			} else {
				maxp--;
				maxans = Math.pow(2, maxp);
				break;
			}
		}
		for (int i = 3; i <= sqrt; i++) {
			while (Math.pow(i, maxp) > x) {
				maxp--;
			}
			if (Math.pow(i, maxp) > maxans) {
				maxans = Math.pow(i, maxp);
			}
		}
		System.out.println((int) maxans);

		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		if (x <= 3) {
			System.out.println(1);
			sc.close();
			return;
		}

		int sqrt = (int) Math.sqrt(x);
		int maxp = 2;
		double maxans = 1;
		while (true) {
			if (Math.pow(2, maxp) < x) {
				maxp++;
			} else {
				maxp--;
				maxans = Math.pow(2, maxp);
				break;
			}
		}
		for (int i = 3; i <= sqrt; i++) {
			while (Math.pow(i, maxp) > x) {
				maxp--;
			}
			if (Math.pow(i, maxp) > maxans) {
				maxans = Math.pow(i, maxp);
			}
		}
		System.out.println((int) maxans);

		sc.close();
	}
}