import java.util.Scanner;;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int max = Integer.MIN_VALUE;
        for(int i = 1;i<=1000;i++){
            for(int j = 2;j<20;j++){
                int tmp = (int)Math.pow(i,j);
                if(tmp>a){
                    break;
                }
                if(max < tmp && tmp<=a){
                    max = tmp;
                }
            }
        }
        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);
        int a = sc.nextInt();
        int max = Integer.MIN_VALUE;
        for(int i = 1;i<=1000;i++){
            for(int j = 2;j<20;j++){
                int tmp = (int)Math.pow(i,j);
                if(tmp>a){
                    break;
                }
                if(max < tmp && tmp<=a){
                    max = tmp;
                }
            }
        }
        System.out.println(max);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int max = Integer.MIN_VALUE;
        for(int i = 1;i<=1000;i++){
            for(int j = 2;j<20;j++){
                int tmp = (int)Math.pow(i,j);
                if(tmp>a){
                    break;
                }
                if(max < tmp && tmp<=a){
                    max = tmp;
                }
            }
        }
        System.out.println(max);
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int max = Integer.MIN_VALUE;
        for(int i = 1;i<=1000;i++){
            for(int j = 2;j<20;j++){
                int tmp = (int)Math.pow(i,j);
                if(tmp>a){
                    break;
                }
                if(max < tmp && tmp<=a){
                    max = tmp;
                }
            }
        }
        System.out.println(max);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int max = Integer.MIN_VALUE; max Integer.MIN_VALUE Integer Integer.MIN_VALUE for(int i = 1;i<=1000;i++){
            for(int j = 2;j<20;j++){
                int tmp = (int)Math.pow(i,j);
                if(tmp>a){
                    break;
                }
                if(max < tmp && tmp<=a){
                    max = tmp;
                }
            }
        } int i = 1; int i = 1; i 1 i<=1000 i 1000 i++ i++ i {
            for(int j = 2;j<20;j++){
                int tmp = (int)Math.pow(i,j);
                if(tmp>a){
                    break;
                }
                if(max < tmp && tmp<=a){
                    max = tmp;
                }
            }
        } {
            for(int j = 2;j<20;j++){
                int tmp = (int)Math.pow(i,j);
                if(tmp>a){
                    break;
                }
                if(max < tmp && tmp<=a){
                    max = tmp;
                }
            }
        } for(int j = 2;j<20;j++){
                int tmp = (int)Math.pow(i,j);
                if(tmp>a){
                    break;
                }
                if(max < tmp && tmp<=a){
                    max = tmp;
                }
            } int j = 2; int j = 2; j 2 j<20 j 20 j++ j++ j {
                int tmp = (int)Math.pow(i,j);
                if(tmp>a){
                    break;
                }
                if(max < tmp && tmp<=a){
                    max = tmp;
                }
            } {
                int tmp = (int)Math.pow(i,j);
                if(tmp>a){
                    break;
                }
                if(max < tmp && tmp<=a){
                    max = tmp;
                }
            } int tmp = (int)Math.pow(i,j); tmp (int)Math.pow(i,j) Math.pow Math i j if(tmp>a){
                    break;
                } tmp>a tmp a {
                    break;
                } break; if(max < tmp && tmp<=a){
                    max = tmp;
                } max < tmp && tmp<=a max < tmp max tmp tmp<=a tmp a {
                    max = tmp;
                } max = tmp max tmp 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);
        int a = sc.nextInt();
        int max = Integer.MIN_VALUE;
        for(int i = 1;i<=1000;i++){
            for(int j = 2;j<20;j++){
                int tmp = (int)Math.pow(i,j);
                if(tmp>a){
                    break;
                }
                if(max < tmp && tmp<=a){
                    max = tmp;
                }
            }
        }
        System.out.println(max);
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int max = Integer.MIN_VALUE;
        for(int i = 1;i<=1000;i++){
            for(int j = 2;j<20;j++){
                int tmp = (int)Math.pow(i,j);
                if(tmp>a){
                    break;
                }
                if(max < tmp && tmp<=a){
                    max = tmp;
                }
            }
        }
        System.out.println(max);
    }
} Main
import java.util.Scanner;;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int max = Integer.MIN_VALUE;
        for(int i = 1;i<=1000;i++){
            for(int j = 2;j<20;j++){
                int tmp = (int)Math.pow(i,j);
                if(tmp>a){
                    break;
                }
                if(max < tmp && tmp<=a){
                    max = tmp;
                }
            }
        }
        System.out.println(max);
    }
}