import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();

		List<Integer> expList = new ArrayList<>();

		for (int i=1; i<=Math.sqrt(X); i++) {
			for (int j=2; j<10; j++) {
				if (Math.pow(i, j)<=X) {
					expList.add((int)Math.pow(i, j));
				}
			}
		}

		Collections.sort(expList);
		System.out.println(expList.get(expList.size()-1));
	}
}
 import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();

		List<Integer> expList = new ArrayList<>();

		for (int i=1; i<=Math.sqrt(X); i++) {
			for (int j=2; j<10; j++) {
				if (Math.pow(i, j)<=X) {
					expList.add((int)Math.pow(i, j));
				}
			}
		}

		Collections.sort(expList);
		System.out.println(expList.get(expList.size()-1));
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();

		List<Integer> expList = new ArrayList<>();

		for (int i=1; i<=Math.sqrt(X); i++) {
			for (int j=2; j<10; j++) {
				if (Math.pow(i, j)<=X) {
					expList.add((int)Math.pow(i, j));
				}
			}
		}

		Collections.sort(expList);
		System.out.println(expList.get(expList.size()-1));
	} main {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();

		List<Integer> expList = new ArrayList<>();

		for (int i=1; i<=Math.sqrt(X); i++) {
			for (int j=2; j<10; j++) {
				if (Math.pow(i, j)<=X) {
					expList.add((int)Math.pow(i, j));
				}
			}
		}

		Collections.sort(expList);
		System.out.println(expList.get(expList.size()-1));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc List<Integer> expList = new ArrayList<>(); expList new ArrayList<>() for (int i=1; i<=Math.sqrt(X); i++) {
			for (int j=2; j<10; j++) {
				if (Math.pow(i, j)<=X) {
					expList.add((int)Math.pow(i, j));
				}
			}
		} int i=1; int i=1; i 1 i<=Math.sqrt(X) i Math.sqrt(X) Math.sqrt Math X i++ i++ i {
			for (int j=2; j<10; j++) {
				if (Math.pow(i, j)<=X) {
					expList.add((int)Math.pow(i, j));
				}
			}
		} {
			for (int j=2; j<10; j++) {
				if (Math.pow(i, j)<=X) {
					expList.add((int)Math.pow(i, j));
				}
			}
		} for (int j=2; j<10; j++) {
				if (Math.pow(i, j)<=X) {
					expList.add((int)Math.pow(i, j));
				}
			} int j=2; int j=2; j 2 j<10 j 10 j++ j++ j {
				if (Math.pow(i, j)<=X) {
					expList.add((int)Math.pow(i, j));
				}
			} {
				if (Math.pow(i, j)<=X) {
					expList.add((int)Math.pow(i, j));
				}
			} if (Math.pow(i, j)<=X) {
					expList.add((int)Math.pow(i, j));
				} Math.pow(i, j)<=X Math.pow(i, j) Math.pow Math i j X {
					expList.add((int)Math.pow(i, j));
				} expList.add((int)Math.pow(i, j)) expList.add expList (int)Math.pow(i, j) Math.pow Math i j Collections.sort(expList) Collections.sort Collections expList System.out.println(expList.get(expList.size()-1)) System.out.println System.out System System.out expList.get(expList.size()-1) expList.get expList expList.size()-1 expList.size() expList.size expList 1 String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();

		List<Integer> expList = new ArrayList<>();

		for (int i=1; i<=Math.sqrt(X); i++) {
			for (int j=2; j<10; j++) {
				if (Math.pow(i, j)<=X) {
					expList.add((int)Math.pow(i, j));
				}
			}
		}

		Collections.sort(expList);
		System.out.println(expList.get(expList.size()-1));
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();

		List<Integer> expList = new ArrayList<>();

		for (int i=1; i<=Math.sqrt(X); i++) {
			for (int j=2; j<10; j++) {
				if (Math.pow(i, j)<=X) {
					expList.add((int)Math.pow(i, j));
				}
			}
		}

		Collections.sort(expList);
		System.out.println(expList.get(expList.size()-1));
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();

		List<Integer> expList = new ArrayList<>();

		for (int i=1; i<=Math.sqrt(X); i++) {
			for (int j=2; j<10; j++) {
				if (Math.pow(i, j)<=X) {
					expList.add((int)Math.pow(i, j));
				}
			}
		}

		Collections.sort(expList);
		System.out.println(expList.get(expList.size()-1));
	}
}

