import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int x = sc.nextInt();
        int max = 0;
        for (int i = 1; i < 32; i++) {
            for (int j = 2; j < 10; j++) {
                int beki = (int) Math.pow(i, j);
                if (beki > x) {
                    continue;
                }

                max = Math.max(beki, max);
            }
        }
        System.out.println(max);
    }
} import java.util.Scanner; Scanner java.util class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int x = sc.nextInt();
        int max = 0;
        for (int i = 1; i < 32; i++) {
            for (int j = 2; j < 10; j++) {
                int beki = (int) Math.pow(i, j);
                if (beki > x) {
                    continue;
                }

                max = Math.max(beki, max);
            }
        }
        System.out.println(max);
    }
} Main private static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
        int x = sc.nextInt();
        int max = 0;
        for (int i = 1; i < 32; i++) {
            for (int j = 2; j < 10; j++) {
                int beki = (int) Math.pow(i, j);
                if (beki > x) {
                    continue;
                }

                max = Math.max(beki, max);
            }
        }
        System.out.println(max);
    } main {
        int x = sc.nextInt();
        int max = 0;
        for (int i = 1; i < 32; i++) {
            for (int j = 2; j < 10; j++) {
                int beki = (int) Math.pow(i, j);
                if (beki > x) {
                    continue;
                }

                max = Math.max(beki, max);
            }
        }
        System.out.println(max);
    } int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int max = 0; max 0 for (int i = 1; i < 32; i++) {
            for (int j = 2; j < 10; j++) {
                int beki = (int) Math.pow(i, j);
                if (beki > x) {
                    continue;
                }

                max = Math.max(beki, max);
            }
        } int i = 1; int i = 1; i 1 i < 32 i 32 i++ i++ i {
            for (int j = 2; j < 10; j++) {
                int beki = (int) Math.pow(i, j);
                if (beki > x) {
                    continue;
                }

                max = Math.max(beki, max);
            }
        } {
            for (int j = 2; j < 10; j++) {
                int beki = (int) Math.pow(i, j);
                if (beki > x) {
                    continue;
                }

                max = Math.max(beki, max);
            }
        } for (int j = 2; j < 10; j++) {
                int beki = (int) Math.pow(i, j);
                if (beki > x) {
                    continue;
                }

                max = Math.max(beki, max);
            } int j = 2; int j = 2; j 2 j < 10 j 10 j++ j++ j {
                int beki = (int) Math.pow(i, j);
                if (beki > x) {
                    continue;
                }

                max = Math.max(beki, max);
            } {
                int beki = (int) Math.pow(i, j);
                if (beki > x) {
                    continue;
                }

                max = Math.max(beki, max);
            } int beki = (int) Math.pow(i, j); beki (int) Math.pow(i, j) Math.pow Math i j if (beki > x) {
                    continue;
                } beki > x beki x {
                    continue;
                } continue; max = Math.max(beki, max) max Math.max(beki, max) Math.max Math beki max System.out.println(max) System.out.println System.out System System.out max String[] args args
import java.util.Scanner;

class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int x = sc.nextInt();
        int max = 0;
        for (int i = 1; i < 32; i++) {
            for (int j = 2; j < 10; j++) {
                int beki = (int) Math.pow(i, j);
                if (beki > x) {
                    continue;
                }

                max = Math.max(beki, max);
            }
        }
        System.out.println(max);
    }
}