import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        int answer =1;
        
        for(int i=2; i*i<=X; i++){
            int max =i*i;
            while(max<=X){
            if(max >= answer){
                answer = max;
            }
                max *= i;
            }
        }
        
        System.out.println(answer);
        
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        int answer =1;
        
        for(int i=2; i*i<=X; i++){
            int max =i*i;
            while(max<=X){
            if(max >= answer){
                answer = max;
            }
                max *= i;
            }
        }
        
        System.out.println(answer);
        
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        int answer =1;
        
        for(int i=2; i*i<=X; i++){
            int max =i*i;
            while(max<=X){
            if(max >= answer){
                answer = max;
            }
                max *= i;
            }
        }
        
        System.out.println(answer);
        
    } main {
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        int answer =1;
        
        for(int i=2; i*i<=X; i++){
            int max =i*i;
            while(max<=X){
            if(max >= answer){
                answer = max;
            }
                max *= i;
            }
        }
        
        System.out.println(answer);
        
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc int answer =1; answer 1 for(int i=2; i*i<=X; i++){
            int max =i*i;
            while(max<=X){
            if(max >= answer){
                answer = max;
            }
                max *= i;
            }
        } int i=2; int i=2; i 2 i*i<=X i*i i i X i++ i++ i {
            int max =i*i;
            while(max<=X){
            if(max >= answer){
                answer = max;
            }
                max *= i;
            }
        } {
            int max =i*i;
            while(max<=X){
            if(max >= answer){
                answer = max;
            }
                max *= i;
            }
        } int max =i*i; max i*i i i while(max<=X){
            if(max >= answer){
                answer = max;
            }
                max *= i;
            } max<=X max X {
            if(max >= answer){
                answer = max;
            }
                max *= i;
            } if(max >= answer){
                answer = max;
            } max >= answer max answer {
                answer = max;
            } answer = max answer max max *= i max i System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        int answer =1;
        
        for(int i=2; i*i<=X; i++){
            int max =i*i;
            while(max<=X){
            if(max >= answer){
                answer = max;
            }
                max *= i;
            }
        }
        
        System.out.println(answer);
        
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        int answer =1;
        
        for(int i=2; i*i<=X; i++){
            int max =i*i;
            while(max<=X){
            if(max >= answer){
                answer = max;
            }
                max *= i;
            }
        }
        
        System.out.println(answer);
        
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        int answer =1;
        
        for(int i=2; i*i<=X; i++){
            int max =i*i;
            while(max<=X){
            if(max >= answer){
                answer = max;
            }
                max *= i;
            }
        }
        
        System.out.println(answer);
        
    }
}
