import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().solove();
    }

    public void solove() {

        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();


        if (x == 1) {
            System.out.println(x);
            return;
        }

        int result = 2;
        
        for (int i = 2; i <= x; i++) {
            for (int j = 2; Math.pow(i, j) <= x; j++) {
                result = Math.max((int) Math.pow(i, j), result);
            }
        }
        System.out.println(result);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        new Main().solove();
    }

    public void solove() {

        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();


        if (x == 1) {
            System.out.println(x);
            return;
        }

        int result = 2;
        
        for (int i = 2; i <= x; i++) {
            for (int j = 2; Math.pow(i, j) <= x; j++) {
                result = Math.max((int) Math.pow(i, j), result);
            }
        }
        System.out.println(result);
    }
} Main public static void main(String[] args) {
        new Main().solove();
    } main {
        new Main().solove();
    } new Main().solove() new Main().solove new Main() String[] args args public void solove() {

        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();


        if (x == 1) {
            System.out.println(x);
            return;
        }

        int result = 2;
        
        for (int i = 2; i <= x; i++) {
            for (int j = 2; Math.pow(i, j) <= x; j++) {
                result = Math.max((int) Math.pow(i, j), result);
            }
        }
        System.out.println(result);
    } solove {

        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();


        if (x == 1) {
            System.out.println(x);
            return;
        }

        int result = 2;
        
        for (int i = 2; i <= x; i++) {
            for (int j = 2; Math.pow(i, j) <= x; j++) {
                result = Math.max((int) Math.pow(i, j), result);
            }
        }
        System.out.println(result);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc if (x == 1) {
            System.out.println(x);
            return;
        } x == 1 x 1 {
            System.out.println(x);
            return;
        } System.out.println(x) System.out.println System.out System System.out x return; int result = 2; result 2 for (int i = 2; i <= x; i++) {
            for (int j = 2; Math.pow(i, j) <= x; j++) {
                result = Math.max((int) Math.pow(i, j), result);
            }
        } int i = 2; int i = 2; i 2 i <= x i x i++ i++ i {
            for (int j = 2; Math.pow(i, j) <= x; j++) {
                result = Math.max((int) Math.pow(i, j), result);
            }
        } {
            for (int j = 2; Math.pow(i, j) <= x; j++) {
                result = Math.max((int) Math.pow(i, j), result);
            }
        } for (int j = 2; Math.pow(i, j) <= x; j++) {
                result = Math.max((int) Math.pow(i, j), result);
            } int j = 2; int j = 2; j 2 Math.pow(i, j) <= x Math.pow(i, j) Math.pow Math i j x j++ j++ j {
                result = Math.max((int) Math.pow(i, j), result);
            } {
                result = Math.max((int) Math.pow(i, j), result);
            } result = Math.max((int) Math.pow(i, j), result) result Math.max((int) Math.pow(i, j), result) Math.max Math (int) Math.pow(i, j) Math.pow Math i j result System.out.println(result) System.out.println System.out System System.out result public class Main {

    public static void main(String[] args) {
        new Main().solove();
    }

    public void solove() {

        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();


        if (x == 1) {
            System.out.println(x);
            return;
        }

        int result = 2;
        
        for (int i = 2; i <= x; i++) {
            for (int j = 2; Math.pow(i, j) <= x; j++) {
                result = Math.max((int) Math.pow(i, j), result);
            }
        }
        System.out.println(result);
    }
} public class Main {

    public static void main(String[] args) {
        new Main().solove();
    }

    public void solove() {

        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();


        if (x == 1) {
            System.out.println(x);
            return;
        }

        int result = 2;
        
        for (int i = 2; i <= x; i++) {
            for (int j = 2; Math.pow(i, j) <= x; j++) {
                result = Math.max((int) Math.pow(i, j), result);
            }
        }
        System.out.println(result);
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().solove();
    }

    public void solove() {

        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();


        if (x == 1) {
            System.out.println(x);
            return;
        }

        int result = 2;
        
        for (int i = 2; i <= x; i++) {
            for (int j = 2; Math.pow(i, j) <= x; j++) {
                result = Math.max((int) Math.pow(i, j), result);
            }
        }
        System.out.println(result);
    }
}
