import java.util.Scanner;

/**
 *
 * @author must
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        
        double tmax=0;
        for (int i=2;i<10;i++){
            for(int k=1;k<32;k++){
                double t = Math.pow(k, i);
                //System.out.println(t);
                if(t > tmax && t<=X){
                    tmax = t;
                    if(t==X){
                        break;
                    }
                }else if(t>X){
                    break;
                }
                
            }
        }
        int ans = (int)tmax;
        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        
        double tmax=0;
        for (int i=2;i<10;i++){
            for(int k=1;k<32;k++){
                double t = Math.pow(k, i);
                //System.out.println(t);
                if(t > tmax && t<=X){
                    tmax = t;
                    if(t==X){
                        break;
                    }
                }else if(t>X){
                    break;
                }
                
            }
        }
        int ans = (int)tmax;
        System.out.println(ans);
    }
} Main /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        
        double tmax=0;
        for (int i=2;i<10;i++){
            for(int k=1;k<32;k++){
                double t = Math.pow(k, i);
                //System.out.println(t);
                if(t > tmax && t<=X){
                    tmax = t;
                    if(t==X){
                        break;
                    }
                }else if(t>X){
                    break;
                }
                
            }
        }
        int ans = (int)tmax;
        System.out.println(ans);
    } main {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        
        double tmax=0;
        for (int i=2;i<10;i++){
            for(int k=1;k<32;k++){
                double t = Math.pow(k, i);
                //System.out.println(t);
                if(t > tmax && t<=X){
                    tmax = t;
                    if(t==X){
                        break;
                    }
                }else if(t>X){
                    break;
                }
                
            }
        }
        int ans = (int)tmax;
        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 double tmax=0; tmax 0 for (int i=2;i<10;i++){
            for(int k=1;k<32;k++){
                double t = Math.pow(k, i);
                //System.out.println(t);
                if(t > tmax && t<=X){
                    tmax = t;
                    if(t==X){
                        break;
                    }
                }else if(t>X){
                    break;
                }
                
            }
        } int i=2; int i=2; i 2 i<10 i 10 i++ i++ i {
            for(int k=1;k<32;k++){
                double t = Math.pow(k, i);
                //System.out.println(t);
                if(t > tmax && t<=X){
                    tmax = t;
                    if(t==X){
                        break;
                    }
                }else if(t>X){
                    break;
                }
                
            }
        } {
            for(int k=1;k<32;k++){
                double t = Math.pow(k, i);
                //System.out.println(t);
                if(t > tmax && t<=X){
                    tmax = t;
                    if(t==X){
                        break;
                    }
                }else if(t>X){
                    break;
                }
                
            }
        } for(int k=1;k<32;k++){
                double t = Math.pow(k, i);
                //System.out.println(t);
                if(t > tmax && t<=X){
                    tmax = t;
                    if(t==X){
                        break;
                    }
                }else if(t>X){
                    break;
                }
                
            } int k=1; int k=1; k 1 k<32 k 32 k++ k++ k {
                double t = Math.pow(k, i);
                //System.out.println(t);
                if(t > tmax && t<=X){
                    tmax = t;
                    if(t==X){
                        break;
                    }
                }else if(t>X){
                    break;
                }
                
            } {
                double t = Math.pow(k, i);
                //System.out.println(t);
                if(t > tmax && t<=X){
                    tmax = t;
                    if(t==X){
                        break;
                    }
                }else if(t>X){
                    break;
                }
                
            } double t = Math.pow(k, i); t Math.pow(k, i) Math.pow Math k i if(t > tmax && t<=X){
                    tmax = t;
                    if(t==X){
                        break;
                    }
                }else if(t>X){
                    break;
                } t > tmax && t<=X t > tmax t tmax t<=X t X {
                    tmax = t;
                    if(t==X){
                        break;
                    }
                } tmax = t tmax t if(t==X){
                        break;
                    } t==X t X {
                        break;
                    } break; if(t>X){
                    break;
                } t>X t X {
                    break;
                } break; int ans = (int)tmax; ans (int)tmax System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        
        double tmax=0;
        for (int i=2;i<10;i++){
            for(int k=1;k<32;k++){
                double t = Math.pow(k, i);
                //System.out.println(t);
                if(t > tmax && t<=X){
                    tmax = t;
                    if(t==X){
                        break;
                    }
                }else if(t>X){
                    break;
                }
                
            }
        }
        int ans = (int)tmax;
        System.out.println(ans);
    }
} public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        
        double tmax=0;
        for (int i=2;i<10;i++){
            for(int k=1;k<32;k++){
                double t = Math.pow(k, i);
                //System.out.println(t);
                if(t > tmax && t<=X){
                    tmax = t;
                    if(t==X){
                        break;
                    }
                }else if(t>X){
                    break;
                }
                
            }
        }
        int ans = (int)tmax;
        System.out.println(ans);
    }
} Main
import java.util.Scanner;

/**
 *
 * @author must
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        
        double tmax=0;
        for (int i=2;i<10;i++){
            for(int k=1;k<32;k++){
                double t = Math.pow(k, i);
                //System.out.println(t);
                if(t > tmax && t<=X){
                    tmax = t;
                    if(t==X){
                        break;
                    }
                }else if(t>X){
                    break;
                }
                
            }
        }
        int ans = (int)tmax;
        System.out.println(ans);
    }
}
