import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(solve(n));
    }
    
    public static int solve(int n){
        int max = (int)Math.pow(n,0.5)+1;
        int ret = 1;
        for(int i = 2; i < max; i++){
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ret = Math.max(ret,(int)Math.pow(i,pow));
                pow++;
            }
        }
        return ret;
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(solve(n));
    }
    
    public static int solve(int n){
        int max = (int)Math.pow(n,0.5)+1;
        int ret = 1;
        for(int i = 2; i < max; i++){
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ret = Math.max(ret,(int)Math.pow(i,pow));
                pow++;
            }
        }
        return ret;
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(solve(n));
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(solve(n));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc System.out.println(solve(n)) System.out.println System.out System System.out solve(n) solve n String[] args args public static int solve(int n){
        int max = (int)Math.pow(n,0.5)+1;
        int ret = 1;
        for(int i = 2; i < max; i++){
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ret = Math.max(ret,(int)Math.pow(i,pow));
                pow++;
            }
        }
        return ret;
    } solve {
        int max = (int)Math.pow(n,0.5)+1;
        int ret = 1;
        for(int i = 2; i < max; i++){
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ret = Math.max(ret,(int)Math.pow(i,pow));
                pow++;
            }
        }
        return ret;
    } int max = (int)Math.pow(n,0.5)+1; max (int)Math.pow(n,0.5)+1 (int)Math.pow(n,0.5) Math.pow Math n 0.5 1 int ret = 1; ret 1 for(int i = 2; i < max; i++){
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ret = Math.max(ret,(int)Math.pow(i,pow));
                pow++;
            }
        } int i = 2; int i = 2; i 2 i < max i max i++ i++ i {
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ret = Math.max(ret,(int)Math.pow(i,pow));
                pow++;
            }
        } {
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ret = Math.max(ret,(int)Math.pow(i,pow));
                pow++;
            }
        } int pow = 2; pow 2 while(Math.pow(i,pow) <= n){
                ret = Math.max(ret,(int)Math.pow(i,pow));
                pow++;
            } Math.pow(i,pow) <= n Math.pow(i,pow) Math.pow Math i pow n {
                ret = Math.max(ret,(int)Math.pow(i,pow));
                pow++;
            } ret = Math.max(ret,(int)Math.pow(i,pow)) ret Math.max(ret,(int)Math.pow(i,pow)) Math.max Math ret (int)Math.pow(i,pow) Math.pow Math i pow pow++ pow return ret; ret int n n public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(solve(n));
    }
    
    public static int solve(int n){
        int max = (int)Math.pow(n,0.5)+1;
        int ret = 1;
        for(int i = 2; i < max; i++){
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ret = Math.max(ret,(int)Math.pow(i,pow));
                pow++;
            }
        }
        return ret;
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println(solve(n));
    }
    
    public static int solve(int n){
        int max = (int)Math.pow(n,0.5)+1;
        int ret = 1;
        for(int i = 2; i < max; i++){
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ret = Math.max(ret,(int)Math.pow(i,pow));
                pow++;
            }
        }
        return ret;
    }
} Main
import java.util.*;

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