import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        
        int X = sc.nextInt();
        sc.close();

        int a = (int)Math.sqrt(X);

        int b = (int)(Math.log(X)/Math.log(2));

        int max = 0;
        loop: for(int i = 1; i <= a; i++){
            for(int j = 2; j <= b; j++){
                if(Math.pow(i, j) > X)
                    continue loop;
                else
                    max = Math.max(max, (int)Math.pow(i, j));
            }
        }
        if(X == 1 || X == 2 || X == 3){
            System.out.println(1);
        } else {
            System.out.println(max);
        }
    }
} import java.util.*; util.* java public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        
        int X = sc.nextInt();
        sc.close();

        int a = (int)Math.sqrt(X);

        int b = (int)(Math.log(X)/Math.log(2));

        int max = 0;
        loop: for(int i = 1; i <= a; i++){
            for(int j = 2; j <= b; j++){
                if(Math.pow(i, j) > X)
                    continue loop;
                else
                    max = Math.max(max, (int)Math.pow(i, j));
            }
        }
        if(X == 1 || X == 2 || X == 3){
            System.out.println(1);
        } else {
            System.out.println(max);
        }
    }
} Main public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        
        int X = sc.nextInt();
        sc.close();

        int a = (int)Math.sqrt(X);

        int b = (int)(Math.log(X)/Math.log(2));

        int max = 0;
        loop: for(int i = 1; i <= a; i++){
            for(int j = 2; j <= b; j++){
                if(Math.pow(i, j) > X)
                    continue loop;
                else
                    max = Math.max(max, (int)Math.pow(i, j));
            }
        }
        if(X == 1 || X == 2 || X == 3){
            System.out.println(1);
        } else {
            System.out.println(max);
        }
    } main {
        Scanner sc = new Scanner(System.in);

        
        int X = sc.nextInt();
        sc.close();

        int a = (int)Math.sqrt(X);

        int b = (int)(Math.log(X)/Math.log(2));

        int max = 0;
        loop: for(int i = 1; i <= a; i++){
            for(int j = 2; j <= b; j++){
                if(Math.pow(i, j) > X)
                    continue loop;
                else
                    max = Math.max(max, (int)Math.pow(i, j));
            }
        }
        if(X == 1 || X == 2 || X == 3){
            System.out.println(1);
        } else {
            System.out.println(max);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc sc.close() sc.close sc int a = (int)Math.sqrt(X); a (int)Math.sqrt(X) Math.sqrt Math X int b = (int)(Math.log(X)/Math.log(2)); b (int)(Math.log(X)/Math.log(2)) Math.log(X) Math.log Math X Math.log(2) Math.log Math 2 int max = 0; max 0 if(X == 1 || X == 2 || X == 3){
            System.out.println(1);
        } else {
            System.out.println(max);
        } X == 1 || X == 2 || X == 3 X == 1 || X == 2 || X == 3 X == 1 X 1 X == 2 X 2 X == 3 X 3 {
            System.out.println(1);
        } System.out.println(1) System.out.println System.out System System.out 1 {
            System.out.println(max);
        } 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 X = sc.nextInt();
        sc.close();

        int a = (int)Math.sqrt(X);

        int b = (int)(Math.log(X)/Math.log(2));

        int max = 0;
        loop: for(int i = 1; i <= a; i++){
            for(int j = 2; j <= b; j++){
                if(Math.pow(i, j) > X)
                    continue loop;
                else
                    max = Math.max(max, (int)Math.pow(i, j));
            }
        }
        if(X == 1 || X == 2 || X == 3){
            System.out.println(1);
        } else {
            System.out.println(max);
        }
    }
} public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        
        int X = sc.nextInt();
        sc.close();

        int a = (int)Math.sqrt(X);

        int b = (int)(Math.log(X)/Math.log(2));

        int max = 0;
        loop: for(int i = 1; i <= a; i++){
            for(int j = 2; j <= b; j++){
                if(Math.pow(i, j) > X)
                    continue loop;
                else
                    max = Math.max(max, (int)Math.pow(i, j));
            }
        }
        if(X == 1 || X == 2 || X == 3){
            System.out.println(1);
        } else {
            System.out.println(max);
        }
    }
} Main
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        
        int X = sc.nextInt();
        sc.close();

        int a = (int)Math.sqrt(X);

        int b = (int)(Math.log(X)/Math.log(2));

        int max = 0;
        loop: for(int i = 1; i <= a; i++){
            for(int j = 2; j <= b; j++){
                if(Math.pow(i, j) > X)
                    continue loop;
                else
                    max = Math.max(max, (int)Math.pow(i, j));
            }
        }
        if(X == 1 || X == 2 || X == 3){
            System.out.println(1);
        } else {
            System.out.println(max);
        }
    }
}