import java.util.Scanner;
import java.util.TreeSet;
 
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		
		TreeSet<Integer> expo = new TreeSet<>();
		expo.add(1);
		for(int i = 1; i <= x; i++) {
			for(int n = 2; n < x; n++) {
				double result = Math.pow((double)i,(double)n);
				if(result > x) {
					break;
				}else {
					expo.add((int)result);
				}
			}
		}
		
		System.out.println(expo.last());
	}
} import java.util.Scanner; Scanner java.util import java.util.TreeSet; TreeSet java.util public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		
		TreeSet<Integer> expo = new TreeSet<>();
		expo.add(1);
		for(int i = 1; i <= x; i++) {
			for(int n = 2; n < x; n++) {
				double result = Math.pow((double)i,(double)n);
				if(result > x) {
					break;
				}else {
					expo.add((int)result);
				}
			}
		}
		
		System.out.println(expo.last());
	}
} Main public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		
		TreeSet<Integer> expo = new TreeSet<>();
		expo.add(1);
		for(int i = 1; i <= x; i++) {
			for(int n = 2; n < x; n++) {
				double result = Math.pow((double)i,(double)n);
				if(result > x) {
					break;
				}else {
					expo.add((int)result);
				}
			}
		}
		
		System.out.println(expo.last());
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		
		TreeSet<Integer> expo = new TreeSet<>();
		expo.add(1);
		for(int i = 1; i <= x; i++) {
			for(int n = 2; n < x; n++) {
				double result = Math.pow((double)i,(double)n);
				if(result > x) {
					break;
				}else {
					expo.add((int)result);
				}
			}
		}
		
		System.out.println(expo.last());
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc TreeSet<Integer> expo = new TreeSet<>(); expo new TreeSet<>() expo.add(1) expo.add expo 1 for(int i = 1; i <= x; i++) {
			for(int n = 2; n < x; n++) {
				double result = Math.pow((double)i,(double)n);
				if(result > x) {
					break;
				}else {
					expo.add((int)result);
				}
			}
		} int i = 1; int i = 1; i 1 i <= x i x i++ i++ i {
			for(int n = 2; n < x; n++) {
				double result = Math.pow((double)i,(double)n);
				if(result > x) {
					break;
				}else {
					expo.add((int)result);
				}
			}
		} {
			for(int n = 2; n < x; n++) {
				double result = Math.pow((double)i,(double)n);
				if(result > x) {
					break;
				}else {
					expo.add((int)result);
				}
			}
		} for(int n = 2; n < x; n++) {
				double result = Math.pow((double)i,(double)n);
				if(result > x) {
					break;
				}else {
					expo.add((int)result);
				}
			} int n = 2; int n = 2; n 2 n < x n x n++ n++ n {
				double result = Math.pow((double)i,(double)n);
				if(result > x) {
					break;
				}else {
					expo.add((int)result);
				}
			} {
				double result = Math.pow((double)i,(double)n);
				if(result > x) {
					break;
				}else {
					expo.add((int)result);
				}
			} double result = Math.pow((double)i,(double)n); result Math.pow((double)i,(double)n) Math.pow Math (double)i (double)n if(result > x) {
					break;
				}else {
					expo.add((int)result);
				} result > x result x {
					break;
				} break; {
					expo.add((int)result);
				} expo.add((int)result) expo.add expo (int)result System.out.println(expo.last()) System.out.println System.out System System.out expo.last() expo.last expo String args[] args public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		
		TreeSet<Integer> expo = new TreeSet<>();
		expo.add(1);
		for(int i = 1; i <= x; i++) {
			for(int n = 2; n < x; n++) {
				double result = Math.pow((double)i,(double)n);
				if(result > x) {
					break;
				}else {
					expo.add((int)result);
				}
			}
		}
		
		System.out.println(expo.last());
	}
} public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		
		TreeSet<Integer> expo = new TreeSet<>();
		expo.add(1);
		for(int i = 1; i <= x; i++) {
			for(int n = 2; n < x; n++) {
				double result = Math.pow((double)i,(double)n);
				if(result > x) {
					break;
				}else {
					expo.add((int)result);
				}
			}
		}
		
		System.out.println(expo.last());
	}
} Main
import java.util.Scanner;
import java.util.TreeSet;
 
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		
		TreeSet<Integer> expo = new TreeSet<>();
		expo.add(1);
		for(int i = 1; i <= x; i++) {
			for(int n = 2; n < x; n++) {
				double result = Math.pow((double)i,(double)n);
				if(result > x) {
					break;
				}else {
					expo.add((int)result);
				}
			}
		}
		
		System.out.println(expo.last());
	}
}