import java.io.*;
import java.util.*;

public class Main{

      public static void main(String []args)/*throws IOException*/{
        
        /*
        InputStreamReader reader=new InputStreamReader(System.in);
 
        BufferedReader input =
			new BufferedReader (new InputStreamReader (System.in));
			
		int key = reader.read();
		String str = input.readLine();
		*/
		Scanner stdIn = new Scanner(System.in);
		
		int x,ans;
		
		x = stdIn.nextInt();
        int b_max = (int)Math.sqrt(x);
		ans = 1;
        if(x >= 4){
		for(int i = 2;i <= b_max;i++){
		    for(int j = 2;Math.pow(i,j) <= x;j++){
		        if(ans < Math.pow(i,j))
		            ans = (int)Math.pow(i,j);
		    }
		}
        }
	    
		System.out.println(ans);
	
     }
} import java.io.*; io.* java import java.util.*; util.* java public class Main{

      public static void main(String []args)/*throws IOException*/{
        
        /*
        InputStreamReader reader=new InputStreamReader(System.in);
 
        BufferedReader input =
			new BufferedReader (new InputStreamReader (System.in));
			
		int key = reader.read();
		String str = input.readLine();
		*/
		Scanner stdIn = new Scanner(System.in);
		
		int x,ans;
		
		x = stdIn.nextInt();
        int b_max = (int)Math.sqrt(x);
		ans = 1;
        if(x >= 4){
		for(int i = 2;i <= b_max;i++){
		    for(int j = 2;Math.pow(i,j) <= x;j++){
		        if(ans < Math.pow(i,j))
		            ans = (int)Math.pow(i,j);
		    }
		}
        }
	    
		System.out.println(ans);
	
     }
} Main public static void main(String []args)/*throws IOException*/{
        
        /*
        InputStreamReader reader=new InputStreamReader(System.in);
 
        BufferedReader input =
			new BufferedReader (new InputStreamReader (System.in));
			
		int key = reader.read();
		String str = input.readLine();
		*/
		Scanner stdIn = new Scanner(System.in);
		
		int x,ans;
		
		x = stdIn.nextInt();
        int b_max = (int)Math.sqrt(x);
		ans = 1;
        if(x >= 4){
		for(int i = 2;i <= b_max;i++){
		    for(int j = 2;Math.pow(i,j) <= x;j++){
		        if(ans < Math.pow(i,j))
		            ans = (int)Math.pow(i,j);
		    }
		}
        }
	    
		System.out.println(ans);
	
     } main {
        
        /*
        InputStreamReader reader=new InputStreamReader(System.in);
 
        BufferedReader input =
			new BufferedReader (new InputStreamReader (System.in));
			
		int key = reader.read();
		String str = input.readLine();
		*/
		Scanner stdIn = new Scanner(System.in);
		
		int x,ans;
		
		x = stdIn.nextInt();
        int b_max = (int)Math.sqrt(x);
		ans = 1;
        if(x >= 4){
		for(int i = 2;i <= b_max;i++){
		    for(int j = 2;Math.pow(i,j) <= x;j++){
		        if(ans < Math.pow(i,j))
		            ans = (int)Math.pow(i,j);
		    }
		}
        }
	    
		System.out.println(ans);
	
     } Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int x x ans; ans x = stdIn.nextInt() x stdIn.nextInt() stdIn.nextInt stdIn int b_max = (int)Math.sqrt(x); b_max (int)Math.sqrt(x) Math.sqrt Math x ans = 1 ans 1 if(x >= 4){
		for(int i = 2;i <= b_max;i++){
		    for(int j = 2;Math.pow(i,j) <= x;j++){
		        if(ans < Math.pow(i,j))
		            ans = (int)Math.pow(i,j);
		    }
		}
        } x >= 4 x 4 {
		for(int i = 2;i <= b_max;i++){
		    for(int j = 2;Math.pow(i,j) <= x;j++){
		        if(ans < Math.pow(i,j))
		            ans = (int)Math.pow(i,j);
		    }
		}
        } for(int i = 2;i <= b_max;i++){
		    for(int j = 2;Math.pow(i,j) <= x;j++){
		        if(ans < Math.pow(i,j))
		            ans = (int)Math.pow(i,j);
		    }
		} int i = 2; int i = 2; i 2 i <= b_max i b_max i++ i++ i {
		    for(int j = 2;Math.pow(i,j) <= x;j++){
		        if(ans < Math.pow(i,j))
		            ans = (int)Math.pow(i,j);
		    }
		} {
		    for(int j = 2;Math.pow(i,j) <= x;j++){
		        if(ans < Math.pow(i,j))
		            ans = (int)Math.pow(i,j);
		    }
		} for(int j = 2;Math.pow(i,j) <= x;j++){
		        if(ans < Math.pow(i,j))
		            ans = (int)Math.pow(i,j);
		    } int j = 2; int j = 2; j 2 Math.pow(i,j) <= x Math.pow(i,j) Math.pow Math i j x j++ j++ j {
		        if(ans < Math.pow(i,j))
		            ans = (int)Math.pow(i,j);
		    } {
		        if(ans < Math.pow(i,j))
		            ans = (int)Math.pow(i,j);
		    } if(ans < Math.pow(i,j))
		            ans = (int)Math.pow(i,j); ans < Math.pow(i,j) ans Math.pow(i,j) Math.pow Math i j ans = (int)Math.pow(i,j) ans (int)Math.pow(i,j) Math.pow Math i j 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)/*throws IOException*/{
        
        /*
        InputStreamReader reader=new InputStreamReader(System.in);
 
        BufferedReader input =
			new BufferedReader (new InputStreamReader (System.in));
			
		int key = reader.read();
		String str = input.readLine();
		*/
		Scanner stdIn = new Scanner(System.in);
		
		int x,ans;
		
		x = stdIn.nextInt();
        int b_max = (int)Math.sqrt(x);
		ans = 1;
        if(x >= 4){
		for(int i = 2;i <= b_max;i++){
		    for(int j = 2;Math.pow(i,j) <= x;j++){
		        if(ans < Math.pow(i,j))
		            ans = (int)Math.pow(i,j);
		    }
		}
        }
	    
		System.out.println(ans);
	
     }
} public class Main{

      public static void main(String []args)/*throws IOException*/{
        
        /*
        InputStreamReader reader=new InputStreamReader(System.in);
 
        BufferedReader input =
			new BufferedReader (new InputStreamReader (System.in));
			
		int key = reader.read();
		String str = input.readLine();
		*/
		Scanner stdIn = new Scanner(System.in);
		
		int x,ans;
		
		x = stdIn.nextInt();
        int b_max = (int)Math.sqrt(x);
		ans = 1;
        if(x >= 4){
		for(int i = 2;i <= b_max;i++){
		    for(int j = 2;Math.pow(i,j) <= x;j++){
		        if(ans < Math.pow(i,j))
		            ans = (int)Math.pow(i,j);
		    }
		}
        }
	    
		System.out.println(ans);
	
     }
} Main
import java.io.*;
import java.util.*;

public class Main{

      public static void main(String []args)/*throws IOException*/{
        
        /*
        InputStreamReader reader=new InputStreamReader(System.in);
 
        BufferedReader input =
			new BufferedReader (new InputStreamReader (System.in));
			
		int key = reader.read();
		String str = input.readLine();
		*/
		Scanner stdIn = new Scanner(System.in);
		
		int x,ans;
		
		x = stdIn.nextInt();
        int b_max = (int)Math.sqrt(x);
		ans = 1;
        if(x >= 4){
		for(int i = 2;i <= b_max;i++){
		    for(int j = 2;Math.pow(i,j) <= x;j++){
		        if(ans < Math.pow(i,j))
		            ans = (int)Math.pow(i,j);
		    }
		}
        }
	    
		System.out.println(ans);
	
     }
}