import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int x = stdIn.nextInt();
        int max = 0;

        int i = 2;
        int j = 2;
        int y = (int)Math.pow(i, j);
        
        while(y <= x){
            while(y <= x){
                if(max < y)
                    max = y;
                j++;
                y = (int)Math.pow(i, j);
            }
            i++;
            j = 2;
            y = (int)Math.pow(i, j);
        }

        if(max == 0)
            max = x;
        
        System.out.println(max);
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int x = stdIn.nextInt();
        int max = 0;

        int i = 2;
        int j = 2;
        int y = (int)Math.pow(i, j);
        
        while(y <= x){
            while(y <= x){
                if(max < y)
                    max = y;
                j++;
                y = (int)Math.pow(i, j);
            }
            i++;
            j = 2;
            y = (int)Math.pow(i, j);
        }

        if(max == 0)
            max = x;
        
        System.out.println(max);
    }
} Main public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int x = stdIn.nextInt();
        int max = 0;

        int i = 2;
        int j = 2;
        int y = (int)Math.pow(i, j);
        
        while(y <= x){
            while(y <= x){
                if(max < y)
                    max = y;
                j++;
                y = (int)Math.pow(i, j);
            }
            i++;
            j = 2;
            y = (int)Math.pow(i, j);
        }

        if(max == 0)
            max = x;
        
        System.out.println(max);
    } main {
        Scanner stdIn = new Scanner(System.in);
        int x = stdIn.nextInt();
        int max = 0;

        int i = 2;
        int j = 2;
        int y = (int)Math.pow(i, j);
        
        while(y <= x){
            while(y <= x){
                if(max < y)
                    max = y;
                j++;
                y = (int)Math.pow(i, j);
            }
            i++;
            j = 2;
            y = (int)Math.pow(i, j);
        }

        if(max == 0)
            max = x;
        
        System.out.println(max);
    } Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int x = stdIn.nextInt(); x stdIn.nextInt() stdIn.nextInt stdIn int max = 0; max 0 int i = 2; i 2 int j = 2; j 2 int y = (int)Math.pow(i, j); y (int)Math.pow(i, j) Math.pow Math i j while(y <= x){
            while(y <= x){
                if(max < y)
                    max = y;
                j++;
                y = (int)Math.pow(i, j);
            }
            i++;
            j = 2;
            y = (int)Math.pow(i, j);
        } y <= x y x {
            while(y <= x){
                if(max < y)
                    max = y;
                j++;
                y = (int)Math.pow(i, j);
            }
            i++;
            j = 2;
            y = (int)Math.pow(i, j);
        } while(y <= x){
                if(max < y)
                    max = y;
                j++;
                y = (int)Math.pow(i, j);
            } y <= x y x {
                if(max < y)
                    max = y;
                j++;
                y = (int)Math.pow(i, j);
            } if(max < y)
                    max = y; max < y max y max = y max y j++ j y = (int)Math.pow(i, j) y (int)Math.pow(i, j) Math.pow Math i j i++ i j = 2 j 2 y = (int)Math.pow(i, j) y (int)Math.pow(i, j) Math.pow Math i j if(max == 0)
            max = x; max == 0 max 0 max = x max x System.out.println(max) System.out.println System.out System System.out max String[] args args
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int x = stdIn.nextInt();
        int max = 0;

        int i = 2;
        int j = 2;
        int y = (int)Math.pow(i, j);
        
        while(y <= x){
            while(y <= x){
                if(max < y)
                    max = y;
                j++;
                y = (int)Math.pow(i, j);
            }
            i++;
            j = 2;
            y = (int)Math.pow(i, j);
        }

        if(max == 0)
            max = x;
        
        System.out.println(max);
    }
}