import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X=sc.nextInt();
		int ans = 0;
		
		for(int b=1; b <= X; b++) {
			for(int p = 2; p <= 1000; p++) {
				if(Math.pow(b,p) <= X) {
					ans = (Math.max((int)Math.pow(b,  p), ans));
					}
				}
		
		}
		
		System.out.println(ans);
		

	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X=sc.nextInt();
		int ans = 0;
		
		for(int b=1; b <= X; b++) {
			for(int p = 2; p <= 1000; p++) {
				if(Math.pow(b,p) <= X) {
					ans = (Math.max((int)Math.pow(b,  p), ans));
					}
				}
		
		}
		
		System.out.println(ans);
		

	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X=sc.nextInt();
		int ans = 0;
		
		for(int b=1; b <= X; b++) {
			for(int p = 2; p <= 1000; p++) {
				if(Math.pow(b,p) <= X) {
					ans = (Math.max((int)Math.pow(b,  p), ans));
					}
				}
		
		}
		
		System.out.println(ans);
		

	} main {
		Scanner sc = new Scanner(System.in);
		int X=sc.nextInt();
		int ans = 0;
		
		for(int b=1; b <= X; b++) {
			for(int p = 2; p <= 1000; p++) {
				if(Math.pow(b,p) <= X) {
					ans = (Math.max((int)Math.pow(b,  p), ans));
					}
				}
		
		}
		
		System.out.println(ans);
		

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X=sc.nextInt(); X sc.nextInt() sc.nextInt sc int ans = 0; ans 0 for(int b=1; b <= X; b++) {
			for(int p = 2; p <= 1000; p++) {
				if(Math.pow(b,p) <= X) {
					ans = (Math.max((int)Math.pow(b,  p), ans));
					}
				}
		
		} int b=1; int b=1; b 1 b <= X b X b++ b++ b {
			for(int p = 2; p <= 1000; p++) {
				if(Math.pow(b,p) <= X) {
					ans = (Math.max((int)Math.pow(b,  p), ans));
					}
				}
		
		} {
			for(int p = 2; p <= 1000; p++) {
				if(Math.pow(b,p) <= X) {
					ans = (Math.max((int)Math.pow(b,  p), ans));
					}
				}
		
		} for(int p = 2; p <= 1000; p++) {
				if(Math.pow(b,p) <= X) {
					ans = (Math.max((int)Math.pow(b,  p), ans));
					}
				} int p = 2; int p = 2; p 2 p <= 1000 p 1000 p++ p++ p {
				if(Math.pow(b,p) <= X) {
					ans = (Math.max((int)Math.pow(b,  p), ans));
					}
				} {
				if(Math.pow(b,p) <= X) {
					ans = (Math.max((int)Math.pow(b,  p), ans));
					}
				} if(Math.pow(b,p) <= X) {
					ans = (Math.max((int)Math.pow(b,  p), ans));
					} Math.pow(b,p) <= X Math.pow(b,p) Math.pow Math b p X {
					ans = (Math.max((int)Math.pow(b,  p), ans));
					} ans = (Math.max((int)Math.pow(b,  p), ans)) ans (Math.max((int)Math.pow(b,  p), ans)) Math.max Math (int)Math.pow(b,  p) Math.pow Math b p ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X=sc.nextInt();
		int ans = 0;
		
		for(int b=1; b <= X; b++) {
			for(int p = 2; p <= 1000; p++) {
				if(Math.pow(b,p) <= X) {
					ans = (Math.max((int)Math.pow(b,  p), ans));
					}
				}
		
		}
		
		System.out.println(ans);
		

	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X=sc.nextInt();
		int ans = 0;
		
		for(int b=1; b <= X; b++) {
			for(int p = 2; p <= 1000; p++) {
				if(Math.pow(b,p) <= X) {
					ans = (Math.max((int)Math.pow(b,  p), ans));
					}
				}
		
		}
		
		System.out.println(ans);
		

	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X=sc.nextInt();
		int ans = 0;
		
		for(int b=1; b <= X; b++) {
			for(int p = 2; p <= 1000; p++) {
				if(Math.pow(b,p) <= X) {
					ans = (Math.max((int)Math.pow(b,  p), ans));
					}
				}
		
		}
		
		System.out.println(ans);
		

	}
}
