import java.util.Scanner;


public class Main {
	
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        long X = sc.nextLong();
        long max = 1;
        
        for(long i=2;i*i<=X;i++){
        	
        	long pow = i*i;
        	
        	for(;pow<=X;pow *= i)
        		if(max<pow)
        			max = pow;
        	
        }
        
        System.out.println(max);
		
	}


		

    
} import java.util.Scanner; Scanner java.util public class Main {
	
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        long X = sc.nextLong();
        long max = 1;
        
        for(long i=2;i*i<=X;i++){
        	
        	long pow = i*i;
        	
        	for(;pow<=X;pow *= i)
        		if(max<pow)
        			max = pow;
        	
        }
        
        System.out.println(max);
		
	}


		

    
} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        long X = sc.nextLong();
        long max = 1;
        
        for(long i=2;i*i<=X;i++){
        	
        	long pow = i*i;
        	
        	for(;pow<=X;pow *= i)
        		if(max<pow)
        			max = pow;
        	
        }
        
        System.out.println(max);
		
	} main {

        Scanner sc = new Scanner(System.in);
        
        long X = sc.nextLong();
        long max = 1;
        
        for(long i=2;i*i<=X;i++){
        	
        	long pow = i*i;
        	
        	for(;pow<=X;pow *= i)
        		if(max<pow)
        			max = pow;
        	
        }
        
        System.out.println(max);
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long X = sc.nextLong(); X sc.nextLong() sc.nextLong sc long max = 1; max 1 for(long i=2;i*i<=X;i++){
        	
        	long pow = i*i;
        	
        	for(;pow<=X;pow *= i)
        		if(max<pow)
        			max = pow;
        	
        } long i=2; long i=2; i 2 i*i<=X i*i i i X i++ i++ i {
        	
        	long pow = i*i;
        	
        	for(;pow<=X;pow *= i)
        		if(max<pow)
        			max = pow;
        	
        } {
        	
        	long pow = i*i;
        	
        	for(;pow<=X;pow *= i)
        		if(max<pow)
        			max = pow;
        	
        } long pow = i*i; pow i*i i i for(;pow<=X;pow *= i)
        		if(max<pow)
        			max = pow; ; pow<=X pow X pow *= i pow *= i pow i if(max<pow)
        			max = pow; if(max<pow)
        			max = pow; max<pow max pow max = pow max pow System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main {
	
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        long X = sc.nextLong();
        long max = 1;
        
        for(long i=2;i*i<=X;i++){
        	
        	long pow = i*i;
        	
        	for(;pow<=X;pow *= i)
        		if(max<pow)
        			max = pow;
        	
        }
        
        System.out.println(max);
		
	}


		

    
} public class Main {
	
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        long X = sc.nextLong();
        long max = 1;
        
        for(long i=2;i*i<=X;i++){
        	
        	long pow = i*i;
        	
        	for(;pow<=X;pow *= i)
        		if(max<pow)
        			max = pow;
        	
        }
        
        System.out.println(max);
		
	}


		

    
} Main
import java.util.Scanner;


public class Main {
	
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        
        long X = sc.nextLong();
        long max = 1;
        
        for(long i=2;i*i<=X;i++){
        	
        	long pow = i*i;
        	
        	for(;pow<=X;pow *= i)
        		if(max<pow)
        			max = pow;
        	
        }
        
        System.out.println(max);
		
	}


		

    
}