import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int max = 1;
        for (int x = X / 2; x > 1; x--) {
            for (int y = X / 2; y > 1; y--) {
                double pow = Math.pow((double) x, (double) (y));
                if (pow > max && pow <= X) {
                    max = ((int) pow);
                }
            }
        }
        System.out.print(max);
    }
} import java.util.Scanner; Scanner java.util class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int max = 1;
        for (int x = X / 2; x > 1; x--) {
            for (int y = X / 2; y > 1; y--) {
                double pow = Math.pow((double) x, (double) (y));
                if (pow > max && pow <= X) {
                    max = ((int) pow);
                }
            }
        }
        System.out.print(max);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int max = 1;
        for (int x = X / 2; x > 1; x--) {
            for (int y = X / 2; y > 1; y--) {
                double pow = Math.pow((double) x, (double) (y));
                if (pow > max && pow <= X) {
                    max = ((int) pow);
                }
            }
        }
        System.out.print(max);
    } main {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int max = 1;
        for (int x = X / 2; x > 1; x--) {
            for (int y = X / 2; y > 1; y--) {
                double pow = Math.pow((double) x, (double) (y));
                if (pow > max && pow <= X) {
                    max = ((int) pow);
                }
            }
        }
        System.out.print(max);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int X = scanner.nextInt(); X scanner.nextInt() scanner.nextInt scanner int max = 1; max 1 for (int x = X / 2; x > 1; x--) {
            for (int y = X / 2; y > 1; y--) {
                double pow = Math.pow((double) x, (double) (y));
                if (pow > max && pow <= X) {
                    max = ((int) pow);
                }
            }
        } int x = X / 2; int x = X / 2; x X / 2 X 2 x > 1 x 1 x-- x-- x {
            for (int y = X / 2; y > 1; y--) {
                double pow = Math.pow((double) x, (double) (y));
                if (pow > max && pow <= X) {
                    max = ((int) pow);
                }
            }
        } {
            for (int y = X / 2; y > 1; y--) {
                double pow = Math.pow((double) x, (double) (y));
                if (pow > max && pow <= X) {
                    max = ((int) pow);
                }
            }
        } for (int y = X / 2; y > 1; y--) {
                double pow = Math.pow((double) x, (double) (y));
                if (pow > max && pow <= X) {
                    max = ((int) pow);
                }
            } int y = X / 2; int y = X / 2; y X / 2 X 2 y > 1 y 1 y-- y-- y {
                double pow = Math.pow((double) x, (double) (y));
                if (pow > max && pow <= X) {
                    max = ((int) pow);
                }
            } {
                double pow = Math.pow((double) x, (double) (y));
                if (pow > max && pow <= X) {
                    max = ((int) pow);
                }
            } double pow = Math.pow((double) x, (double) (y)); pow Math.pow((double) x, (double) (y)) Math.pow Math (double) x (double) (y) if (pow > max && pow <= X) {
                    max = ((int) pow);
                } pow > max && pow <= X pow > max pow max pow <= X pow X {
                    max = ((int) pow);
                } max = ((int) pow) max ((int) pow) System.out.print(max) System.out.print System.out System System.out max String[] args args
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int max = 1;
        for (int x = X / 2; x > 1; x--) {
            for (int y = X / 2; y > 1; y--) {
                double pow = Math.pow((double) x, (double) (y));
                if (pow > max && pow <= X) {
                    max = ((int) pow);
                }
            }
        }
        System.out.print(max);
    }
}
