import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		//String N = in.nextLine();
		double a = in.nextDouble();
		int b = (int)Math.sqrt(a);
		int max = 1;
		for(int i=2; i<=b; i++){
			int tmp = i;
			while(true){
				if(tmp*i <= a){
					tmp = tmp * i; 
					if(max < tmp){
						max = tmp;
					}
				}else{
					break;
				}
			}
		}
		System.out.print(max);
	
		in.close();
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		//String N = in.nextLine();
		double a = in.nextDouble();
		int b = (int)Math.sqrt(a);
		int max = 1;
		for(int i=2; i<=b; i++){
			int tmp = i;
			while(true){
				if(tmp*i <= a){
					tmp = tmp * i; 
					if(max < tmp){
						max = tmp;
					}
				}else{
					break;
				}
			}
		}
		System.out.print(max);
	
		in.close();
	}
} Main public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		//String N = in.nextLine();
		double a = in.nextDouble();
		int b = (int)Math.sqrt(a);
		int max = 1;
		for(int i=2; i<=b; i++){
			int tmp = i;
			while(true){
				if(tmp*i <= a){
					tmp = tmp * i; 
					if(max < tmp){
						max = tmp;
					}
				}else{
					break;
				}
			}
		}
		System.out.print(max);
	
		in.close();
	} main {
		Scanner in = new java.util.Scanner(System.in);
		//String N = in.nextLine();
		double a = in.nextDouble();
		int b = (int)Math.sqrt(a);
		int max = 1;
		for(int i=2; i<=b; i++){
			int tmp = i;
			while(true){
				if(tmp*i <= a){
					tmp = tmp * i; 
					if(max < tmp){
						max = tmp;
					}
				}else{
					break;
				}
			}
		}
		System.out.print(max);
	
		in.close();
	} Scanner in = new java.util.Scanner(System.in); in new java.util.Scanner(System.in) double a = in.nextDouble(); a in.nextDouble() in.nextDouble in int b = (int)Math.sqrt(a); b (int)Math.sqrt(a) Math.sqrt Math a int max = 1; max 1 for(int i=2; i<=b; i++){
			int tmp = i;
			while(true){
				if(tmp*i <= a){
					tmp = tmp * i; 
					if(max < tmp){
						max = tmp;
					}
				}else{
					break;
				}
			}
		} int i=2; int i=2; i 2 i<=b i b i++ i++ i {
			int tmp = i;
			while(true){
				if(tmp*i <= a){
					tmp = tmp * i; 
					if(max < tmp){
						max = tmp;
					}
				}else{
					break;
				}
			}
		} {
			int tmp = i;
			while(true){
				if(tmp*i <= a){
					tmp = tmp * i; 
					if(max < tmp){
						max = tmp;
					}
				}else{
					break;
				}
			}
		} int tmp = i; tmp i while(true){
				if(tmp*i <= a){
					tmp = tmp * i; 
					if(max < tmp){
						max = tmp;
					}
				}else{
					break;
				}
			} true {
				if(tmp*i <= a){
					tmp = tmp * i; 
					if(max < tmp){
						max = tmp;
					}
				}else{
					break;
				}
			} if(tmp*i <= a){
					tmp = tmp * i; 
					if(max < tmp){
						max = tmp;
					}
				}else{
					break;
				} tmp*i <= a tmp*i tmp i a {
					tmp = tmp * i; 
					if(max < tmp){
						max = tmp;
					}
				} tmp = tmp * i tmp tmp * i tmp i if(max < tmp){
						max = tmp;
					} max < tmp max tmp {
						max = tmp;
					} max = tmp max tmp {
					break;
				} break; System.out.print(max) System.out.print System.out System System.out max in.close() in.close in String[] args args public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		//String N = in.nextLine();
		double a = in.nextDouble();
		int b = (int)Math.sqrt(a);
		int max = 1;
		for(int i=2; i<=b; i++){
			int tmp = i;
			while(true){
				if(tmp*i <= a){
					tmp = tmp * i; 
					if(max < tmp){
						max = tmp;
					}
				}else{
					break;
				}
			}
		}
		System.out.print(max);
	
		in.close();
	}
} public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		//String N = in.nextLine();
		double a = in.nextDouble();
		int b = (int)Math.sqrt(a);
		int max = 1;
		for(int i=2; i<=b; i++){
			int tmp = i;
			while(true){
				if(tmp*i <= a){
					tmp = tmp * i; 
					if(max < tmp){
						max = tmp;
					}
				}else{
					break;
				}
			}
		}
		System.out.print(max);
	
		in.close();
	}
} Main
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		//String N = in.nextLine();
		double a = in.nextDouble();
		int b = (int)Math.sqrt(a);
		int max = 1;
		for(int i=2; i<=b; i++){
			int tmp = i;
			while(true){
				if(tmp*i <= a){
					tmp = tmp * i; 
					if(max < tmp){
						max = tmp;
					}
				}else{
					break;
				}
			}
		}
		System.out.print(max);
	
		in.close();
	}
}