import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int max = 1;
        
        for(int i = 2; i < x; i++){
            int exp = i * i;
            
            while(exp <= x){
                max = Math.max(exp,max);
                exp = exp * i;
            }
        }
        System.out.println(max);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int max = 1;
        
        for(int i = 2; i < x; i++){
            int exp = i * i;
            
            while(exp <= x){
                max = Math.max(exp,max);
                exp = exp * i;
            }
        }
        System.out.println(max);
    }
} Main public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int max = 1;
        
        for(int i = 2; i < x; i++){
            int exp = i * i;
            
            while(exp <= x){
                max = Math.max(exp,max);
                exp = exp * i;
            }
        }
        System.out.println(max);
    } main {
        
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int max = 1;
        
        for(int i = 2; i < x; i++){
            int exp = i * i;
            
            while(exp <= x){
                max = Math.max(exp,max);
                exp = exp * i;
            }
        }
        System.out.println(max);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int max = 1; max 1 for(int i = 2; i < x; i++){
            int exp = i * i;
            
            while(exp <= x){
                max = Math.max(exp,max);
                exp = exp * i;
            }
        } int i = 2; int i = 2; i 2 i < x i x i++ i++ i {
            int exp = i * i;
            
            while(exp <= x){
                max = Math.max(exp,max);
                exp = exp * i;
            }
        } {
            int exp = i * i;
            
            while(exp <= x){
                max = Math.max(exp,max);
                exp = exp * i;
            }
        } int exp = i * i; exp i * i i i while(exp <= x){
                max = Math.max(exp,max);
                exp = exp * i;
            } exp <= x exp x {
                max = Math.max(exp,max);
                exp = exp * i;
            } max = Math.max(exp,max) max Math.max(exp,max) Math.max Math exp max exp = exp * i exp exp * i exp i 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) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int max = 1;
        
        for(int i = 2; i < x; i++){
            int exp = i * i;
            
            while(exp <= x){
                max = Math.max(exp,max);
                exp = exp * i;
            }
        }
        System.out.println(max);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int max = 1;
        
        for(int i = 2; i < x; i++){
            int exp = i * i;
            
            while(exp <= x){
                max = Math.max(exp,max);
                exp = exp * i;
            }
        }
        System.out.println(max);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int max = 1;
        
        for(int i = 2; i < x; i++){
            int exp = i * i;
            
            while(exp <= x){
                max = Math.max(exp,max);
                exp = exp * i;
            }
        }
        System.out.println(max);
    }
}
