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 rX = (int)Math.sqrt((double)X);       
        
        int ans = 0;
        for(int i = 1; i <= rX; i++) {
            for(int j = 1; j <= 10; j++ ) {
                int a = (int)Math.pow( i, j );
                if( a > X ) {
                    continue;
                }
                ans = Math.max( ans, a );
            }
        }
        
        System.out.println(ans);
    }
} 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 rX = (int)Math.sqrt((double)X);       
        
        int ans = 0;
        for(int i = 1; i <= rX; i++) {
            for(int j = 1; j <= 10; j++ ) {
                int a = (int)Math.pow( i, j );
                if( a > X ) {
                    continue;
                }
                ans = Math.max( ans, a );
            }
        }
        
        System.out.println(ans);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int rX = (int)Math.sqrt((double)X);       
        
        int ans = 0;
        for(int i = 1; i <= rX; i++) {
            for(int j = 1; j <= 10; j++ ) {
                int a = (int)Math.pow( i, j );
                if( a > X ) {
                    continue;
                }
                ans = Math.max( ans, a );
            }
        }
        
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int rX = (int)Math.sqrt((double)X);       
        
        int ans = 0;
        for(int i = 1; i <= rX; i++) {
            for(int j = 1; j <= 10; j++ ) {
                int a = (int)Math.pow( i, j );
                if( a > X ) {
                    continue;
                }
                ans = Math.max( ans, a );
            }
        }
        
        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 int rX = (int)Math.sqrt((double)X); rX (int)Math.sqrt((double)X) Math.sqrt Math (double)X int ans = 0; ans 0 for(int i = 1; i <= rX; i++) {
            for(int j = 1; j <= 10; j++ ) {
                int a = (int)Math.pow( i, j );
                if( a > X ) {
                    continue;
                }
                ans = Math.max( ans, a );
            }
        } int i = 1; int i = 1; i 1 i <= rX i rX i++ i++ i {
            for(int j = 1; j <= 10; j++ ) {
                int a = (int)Math.pow( i, j );
                if( a > X ) {
                    continue;
                }
                ans = Math.max( ans, a );
            }
        } {
            for(int j = 1; j <= 10; j++ ) {
                int a = (int)Math.pow( i, j );
                if( a > X ) {
                    continue;
                }
                ans = Math.max( ans, a );
            }
        } for(int j = 1; j <= 10; j++ ) {
                int a = (int)Math.pow( i, j );
                if( a > X ) {
                    continue;
                }
                ans = Math.max( ans, a );
            } int j = 1; int j = 1; j 1 j <= 10 j 10 j++ j++ j {
                int a = (int)Math.pow( i, j );
                if( a > X ) {
                    continue;
                }
                ans = Math.max( ans, a );
            } {
                int a = (int)Math.pow( i, j );
                if( a > X ) {
                    continue;
                }
                ans = Math.max( ans, a );
            } int a = (int)Math.pow( i, j ); a (int)Math.pow( i, j ) Math.pow Math i j if( a > X ) {
                    continue;
                } a > X a X {
                    continue;
                } continue; ans = Math.max( ans, a ) ans Math.max( ans, a ) Math.max Math ans a 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 Exception {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int rX = (int)Math.sqrt((double)X);       
        
        int ans = 0;
        for(int i = 1; i <= rX; i++) {
            for(int j = 1; j <= 10; j++ ) {
                int a = (int)Math.pow( i, j );
                if( a > X ) {
                    continue;
                }
                ans = Math.max( ans, a );
            }
        }
        
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int rX = (int)Math.sqrt((double)X);       
        
        int ans = 0;
        for(int i = 1; i <= rX; i++) {
            for(int j = 1; j <= 10; j++ ) {
                int a = (int)Math.pow( i, j );
                if( a > X ) {
                    continue;
                }
                ans = Math.max( ans, a );
            }
        }
        
        System.out.println(ans);
    }
} 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 rX = (int)Math.sqrt((double)X);       
        
        int ans = 0;
        for(int i = 1; i <= rX; i++) {
            for(int j = 1; j <= 10; j++ ) {
                int a = (int)Math.pow( i, j );
                if( a > X ) {
                    continue;
                }
                ans = Math.max( ans, a );
            }
        }
        
        System.out.println(ans);
    }
}
