import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int max = 1;

        for (int j = 2; j <= 31; j++) {
            int n = j * j;
            if (n <= x) {
                while (n * j <= x) {
                    n *= j;
                }
                max = Math.max(max, n);
            }

        }

        System.out.println(max);
    }

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

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int max = 1;

        for (int j = 2; j <= 31; j++) {
            int n = j * j;
            if (n <= x) {
                while (n * j <= x) {
                    n *= j;
                }
                max = Math.max(max, n);
            }

        }

        System.out.println(max);
    }

} Main public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int max = 1;

        for (int j = 2; j <= 31; j++) {
            int n = j * j;
            if (n <= x) {
                while (n * j <= x) {
                    n *= j;
                }
                max = Math.max(max, n);
            }

        }

        System.out.println(max);
    } main {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int max = 1;

        for (int j = 2; j <= 31; j++) {
            int n = j * j;
            if (n <= x) {
                while (n * j <= x) {
                    n *= j;
                }
                max = Math.max(max, n);
            }

        }

        System.out.println(max);
    } @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int max = 1; max 1 for (int j = 2; j <= 31; j++) {
            int n = j * j;
            if (n <= x) {
                while (n * j <= x) {
                    n *= j;
                }
                max = Math.max(max, n);
            }

        } int j = 2; int j = 2; j 2 j <= 31 j 31 j++ j++ j {
            int n = j * j;
            if (n <= x) {
                while (n * j <= x) {
                    n *= j;
                }
                max = Math.max(max, n);
            }

        } {
            int n = j * j;
            if (n <= x) {
                while (n * j <= x) {
                    n *= j;
                }
                max = Math.max(max, n);
            }

        } int n = j * j; n j * j j j if (n <= x) {
                while (n * j <= x) {
                    n *= j;
                }
                max = Math.max(max, n);
            } n <= x n x {
                while (n * j <= x) {
                    n *= j;
                }
                max = Math.max(max, n);
            } while (n * j <= x) {
                    n *= j;
                } n * j <= x n * j n j x {
                    n *= j;
                } n *= j n j max = Math.max(max, n) max Math.max(max, n) Math.max Math max n 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) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int max = 1;

        for (int j = 2; j <= 31; j++) {
            int n = j * j;
            if (n <= x) {
                while (n * j <= x) {
                    n *= j;
                }
                max = Math.max(max, n);
            }

        }

        System.out.println(max);
    }

} public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int max = 1;

        for (int j = 2; j <= 31; j++) {
            int n = j * j;
            if (n <= x) {
                while (n * j <= x) {
                    n *= j;
                }
                max = Math.max(max, n);
            }

        }

        System.out.println(max);
    }

} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int max = 1;

        for (int j = 2; j <= 31; j++) {
            int n = j * j;
            if (n <= x) {
                while (n * j <= x) {
                    n *= j;
                }
                max = Math.max(max, n);
            }

        }

        System.out.println(max);
    }

}
