import java.util.Scanner;

public class Main {

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

            int ans = 1;
            for (int i = x; i > 0; i--) {
                boolean ok = false;
                for (int b = 1; b <= 40; b++) {
                    for (int p = 2; p <= 10; p++) {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    }
                    if (ok) {
                        break;
                    }
                }
                if (ok) {
                    break;
                }
            }

            System.out.println(ans);
        }
    }

    // baseのn乗を計算を返す
    static int pow(int base, int n) {
        int ret = 1;
        for (int i = 0; i < n; i++) {
            ret *= base;
        }
        return ret;
    }

} import java.util.Scanner; Scanner java.util public class Main {

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

            int ans = 1;
            for (int i = x; i > 0; i--) {
                boolean ok = false;
                for (int b = 1; b <= 40; b++) {
                    for (int p = 2; p <= 10; p++) {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    }
                    if (ok) {
                        break;
                    }
                }
                if (ok) {
                    break;
                }
            }

            System.out.println(ans);
        }
    }

    // baseのn乗を計算を返す
    static int pow(int base, int n) {
        int ret = 1;
        for (int i = 0; i < n; i++) {
            ret *= base;
        }
        return ret;
    }

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

            int ans = 1;
            for (int i = x; i > 0; i--) {
                boolean ok = false;
                for (int b = 1; b <= 40; b++) {
                    for (int p = 2; p <= 10; p++) {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    }
                    if (ok) {
                        break;
                    }
                }
                if (ok) {
                    break;
                }
            }

            System.out.println(ans);
        }
    } main {
        try (Scanner sc = new Scanner(System.in)) {
            int x = sc.nextInt();

            int ans = 1;
            for (int i = x; i > 0; i--) {
                boolean ok = false;
                for (int b = 1; b <= 40; b++) {
                    for (int p = 2; p <= 10; p++) {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    }
                    if (ok) {
                        break;
                    }
                }
                if (ok) {
                    break;
                }
            }

            System.out.println(ans);
        }
    } try (Scanner sc = new Scanner(System.in)) {
            int x = sc.nextInt();

            int ans = 1;
            for (int i = x; i > 0; i--) {
                boolean ok = false;
                for (int b = 1; b <= 40; b++) {
                    for (int p = 2; p <= 10; p++) {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    }
                    if (ok) {
                        break;
                    }
                }
                if (ok) {
                    break;
                }
            }

            System.out.println(ans);
        } {
            int x = sc.nextInt();

            int ans = 1;
            for (int i = x; i > 0; i--) {
                boolean ok = false;
                for (int b = 1; b <= 40; b++) {
                    for (int p = 2; p <= 10; p++) {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    }
                    if (ok) {
                        break;
                    }
                }
                if (ok) {
                    break;
                }
            }

            System.out.println(ans);
        } Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int ans = 1; ans 1 for (int i = x; i > 0; i--) {
                boolean ok = false;
                for (int b = 1; b <= 40; b++) {
                    for (int p = 2; p <= 10; p++) {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    }
                    if (ok) {
                        break;
                    }
                }
                if (ok) {
                    break;
                }
            } int i = x; int i = x; i x i > 0 i 0 i-- i-- i {
                boolean ok = false;
                for (int b = 1; b <= 40; b++) {
                    for (int p = 2; p <= 10; p++) {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    }
                    if (ok) {
                        break;
                    }
                }
                if (ok) {
                    break;
                }
            } {
                boolean ok = false;
                for (int b = 1; b <= 40; b++) {
                    for (int p = 2; p <= 10; p++) {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    }
                    if (ok) {
                        break;
                    }
                }
                if (ok) {
                    break;
                }
            } boolean ok = false; ok false for (int b = 1; b <= 40; b++) {
                    for (int p = 2; p <= 10; p++) {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    }
                    if (ok) {
                        break;
                    }
                } int b = 1; int b = 1; b 1 b <= 40 b 40 b++ b++ b {
                    for (int p = 2; p <= 10; p++) {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    }
                    if (ok) {
                        break;
                    }
                } {
                    for (int p = 2; p <= 10; p++) {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    }
                    if (ok) {
                        break;
                    }
                } for (int p = 2; p <= 10; p++) {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    } int p = 2; int p = 2; p 2 p <= 10 p 10 p++ p++ p {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    } {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    } if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        } i == pow(b, p) i pow(b, p) pow b p {
                            ans = i;
                            ok = true;
                            break;
                        } ans = i ans i ok = true ok true break; if (ok) {
                        break;
                    } ok {
                        break;
                    } break; if (ok) {
                    break;
                } ok {
                    break;
                } break; System.out.println(ans) System.out.println System.out System System.out ans String[] args args // baseのn乗を計算を返す
    static int pow(int base, int n) {
        int ret = 1;
        for (int i = 0; i < n; i++) {
            ret *= base;
        }
        return ret;
    } pow {
        int ret = 1;
        for (int i = 0; i < n; i++) {
            ret *= base;
        }
        return ret;
    } int ret = 1; ret 1 for (int i = 0; i < n; i++) {
            ret *= base;
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            ret *= base;
        } {
            ret *= base;
        } ret *= base ret base return ret; ret int base base int n n public class Main {

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

            int ans = 1;
            for (int i = x; i > 0; i--) {
                boolean ok = false;
                for (int b = 1; b <= 40; b++) {
                    for (int p = 2; p <= 10; p++) {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    }
                    if (ok) {
                        break;
                    }
                }
                if (ok) {
                    break;
                }
            }

            System.out.println(ans);
        }
    }

    // baseのn乗を計算を返す
    static int pow(int base, int n) {
        int ret = 1;
        for (int i = 0; i < n; i++) {
            ret *= base;
        }
        return ret;
    }

} public class Main {

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

            int ans = 1;
            for (int i = x; i > 0; i--) {
                boolean ok = false;
                for (int b = 1; b <= 40; b++) {
                    for (int p = 2; p <= 10; p++) {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    }
                    if (ok) {
                        break;
                    }
                }
                if (ok) {
                    break;
                }
            }

            System.out.println(ans);
        }
    }

    // baseのn乗を計算を返す
    static int pow(int base, int n) {
        int ret = 1;
        for (int i = 0; i < n; i++) {
            ret *= base;
        }
        return ret;
    }

} Main
import java.util.Scanner;

public class Main {

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

            int ans = 1;
            for (int i = x; i > 0; i--) {
                boolean ok = false;
                for (int b = 1; b <= 40; b++) {
                    for (int p = 2; p <= 10; p++) {
                        if (i == pow(b, p)) {
                            ans = i;
                            ok = true;
                            break;
                        }
                    }
                    if (ok) {
                        break;
                    }
                }
                if (ok) {
                    break;
                }
            }

            System.out.println(ans);
        }
    }

    // baseのn乗を計算を返す
    static int pow(int base, int n) {
        int ret = 1;
        for (int i = 0; i < n; i++) {
            ret *= base;
        }
        return ret;
    }

}
