import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int X = in.nextInt();

            boolean[] isBeki = new boolean[X + 1];
            isBeki[1] = true;
            bLoop: for (int b = 2; b < Math.sqrt(X) + 1; b++) {
                for (int n = b * b;; n *= b) {
                    if (n > X) {
                        continue bLoop;
                    }
                    isBeki[n] = true;
                }
            }

            for (int i = X; i >= 1; i--) {
                if (isBeki[i]) {
                    System.out.println(i);
                    return;
                }
            }
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int X = in.nextInt();

            boolean[] isBeki = new boolean[X + 1];
            isBeki[1] = true;
            bLoop: for (int b = 2; b < Math.sqrt(X) + 1; b++) {
                for (int n = b * b;; n *= b) {
                    if (n > X) {
                        continue bLoop;
                    }
                    isBeki[n] = true;
                }
            }

            for (int i = X; i >= 1; i--) {
                if (isBeki[i]) {
                    System.out.println(i);
                    return;
                }
            }
        }
    }
} Main public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int X = in.nextInt();

            boolean[] isBeki = new boolean[X + 1];
            isBeki[1] = true;
            bLoop: for (int b = 2; b < Math.sqrt(X) + 1; b++) {
                for (int n = b * b;; n *= b) {
                    if (n > X) {
                        continue bLoop;
                    }
                    isBeki[n] = true;
                }
            }

            for (int i = X; i >= 1; i--) {
                if (isBeki[i]) {
                    System.out.println(i);
                    return;
                }
            }
        }
    } main {
        try (Scanner in = new Scanner(System.in)) {
            int X = in.nextInt();

            boolean[] isBeki = new boolean[X + 1];
            isBeki[1] = true;
            bLoop: for (int b = 2; b < Math.sqrt(X) + 1; b++) {
                for (int n = b * b;; n *= b) {
                    if (n > X) {
                        continue bLoop;
                    }
                    isBeki[n] = true;
                }
            }

            for (int i = X; i >= 1; i--) {
                if (isBeki[i]) {
                    System.out.println(i);
                    return;
                }
            }
        }
    } try (Scanner in = new Scanner(System.in)) {
            int X = in.nextInt();

            boolean[] isBeki = new boolean[X + 1];
            isBeki[1] = true;
            bLoop: for (int b = 2; b < Math.sqrt(X) + 1; b++) {
                for (int n = b * b;; n *= b) {
                    if (n > X) {
                        continue bLoop;
                    }
                    isBeki[n] = true;
                }
            }

            for (int i = X; i >= 1; i--) {
                if (isBeki[i]) {
                    System.out.println(i);
                    return;
                }
            }
        } {
            int X = in.nextInt();

            boolean[] isBeki = new boolean[X + 1];
            isBeki[1] = true;
            bLoop: for (int b = 2; b < Math.sqrt(X) + 1; b++) {
                for (int n = b * b;; n *= b) {
                    if (n > X) {
                        continue bLoop;
                    }
                    isBeki[n] = true;
                }
            }

            for (int i = X; i >= 1; i--) {
                if (isBeki[i]) {
                    System.out.println(i);
                    return;
                }
            }
        } Scanner in = new Scanner(System.in) Scanner in = new Scanner(System.in) new Scanner(System.in) int X = in.nextInt(); X in.nextInt() in.nextInt in boolean[] isBeki = new boolean[X + 1]; isBeki new boolean[X + 1] X + 1 X 1 isBeki[1] = true isBeki[1] isBeki 1 true for (int i = X; i >= 1; i--) {
                if (isBeki[i]) {
                    System.out.println(i);
                    return;
                }
            } int i = X; int i = X; i X i >= 1 i 1 i-- i-- i {
                if (isBeki[i]) {
                    System.out.println(i);
                    return;
                }
            } {
                if (isBeki[i]) {
                    System.out.println(i);
                    return;
                }
            } if (isBeki[i]) {
                    System.out.println(i);
                    return;
                } isBeki[i] isBeki i {
                    System.out.println(i);
                    return;
                } System.out.println(i) System.out.println System.out System System.out i return; String args[] args public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int X = in.nextInt();

            boolean[] isBeki = new boolean[X + 1];
            isBeki[1] = true;
            bLoop: for (int b = 2; b < Math.sqrt(X) + 1; b++) {
                for (int n = b * b;; n *= b) {
                    if (n > X) {
                        continue bLoop;
                    }
                    isBeki[n] = true;
                }
            }

            for (int i = X; i >= 1; i--) {
                if (isBeki[i]) {
                    System.out.println(i);
                    return;
                }
            }
        }
    }
} public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int X = in.nextInt();

            boolean[] isBeki = new boolean[X + 1];
            isBeki[1] = true;
            bLoop: for (int b = 2; b < Math.sqrt(X) + 1; b++) {
                for (int n = b * b;; n *= b) {
                    if (n > X) {
                        continue bLoop;
                    }
                    isBeki[n] = true;
                }
            }

            for (int i = X; i >= 1; i--) {
                if (isBeki[i]) {
                    System.out.println(i);
                    return;
                }
            }
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int X = in.nextInt();

            boolean[] isBeki = new boolean[X + 1];
            isBeki[1] = true;
            bLoop: for (int b = 2; b < Math.sqrt(X) + 1; b++) {
                for (int n = b * b;; n *= b) {
                    if (n > X) {
                        continue bLoop;
                    }
                    isBeki[n] = true;
                }
            }

            for (int i = X; i >= 1; i--) {
                if (isBeki[i]) {
                    System.out.println(i);
                    return;
                }
            }
        }
    }
}
