

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int ans = 1;
            for (int b = 2; b <= n; b++) {
                int x = b * b;
                while (x <= n) {
                    ans = Math.max(ans, x);
                    x *= b;
                }
            }
            System.out.println(ans);
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int ans = 1;
            for (int b = 2; b <= n; b++) {
                int x = b * b;
                while (x <= n) {
                    ans = Math.max(ans, x);
                    x *= b;
                }
            }
            System.out.println(ans);
        }
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int ans = 1;
            for (int b = 2; b <= n; b++) {
                int x = b * b;
                while (x <= n) {
                    ans = Math.max(ans, x);
                    x *= b;
                }
            }
            System.out.println(ans);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int ans = 1;
            for (int b = 2; b <= n; b++) {
                int x = b * b;
                while (x <= n) {
                    ans = Math.max(ans, x);
                    x *= b;
                }
            }
            System.out.println(ans);
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int ans = 1;
            for (int b = 2; b <= n; b++) {
                int x = b * b;
                while (x <= n) {
                    ans = Math.max(ans, x);
                    x *= b;
                }
            }
            System.out.println(ans);
        } sc.hasNextInt() sc.hasNextInt sc {
            int n = sc.nextInt();
            int ans = 1;
            for (int b = 2; b <= n; b++) {
                int x = b * b;
                while (x <= n) {
                    ans = Math.max(ans, x);
                    x *= b;
                }
            }
            System.out.println(ans);
        } int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int ans = 1; ans 1 for (int b = 2; b <= n; b++) {
                int x = b * b;
                while (x <= n) {
                    ans = Math.max(ans, x);
                    x *= b;
                }
            } int b = 2; int b = 2; b 2 b <= n b n b++ b++ b {
                int x = b * b;
                while (x <= n) {
                    ans = Math.max(ans, x);
                    x *= b;
                }
            } {
                int x = b * b;
                while (x <= n) {
                    ans = Math.max(ans, x);
                    x *= b;
                }
            } int x = b * b; x b * b b b while (x <= n) {
                    ans = Math.max(ans, x);
                    x *= b;
                } x <= n x n {
                    ans = Math.max(ans, x);
                    x *= b;
                } ans = Math.max(ans, x) ans Math.max(ans, x) Math.max Math ans x x *= b x b System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int ans = 1;
            for (int b = 2; b <= n; b++) {
                int x = b * b;
                while (x <= n) {
                    ans = Math.max(ans, x);
                    x *= b;
                }
            }
            System.out.println(ans);
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int ans = 1;
            for (int b = 2; b <= n; b++) {
                int x = b * b;
                while (x <= n) {
                    ans = Math.max(ans, x);
                    x *= b;
                }
            }
            System.out.println(ans);
        }
    }
} Main


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int ans = 1;
            for (int b = 2; b <= n; b++) {
                int x = b * b;
                while (x <= n) {
                    ans = Math.max(ans, x);
                    x *= b;
                }
            }
            System.out.println(ans);
        }
    }
}
