import java.util.Scanner;

public class Main {

    static int X;

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

        solve();
    }

    static void solve() {
        int MAX_ROOT = (int)Math.sqrt(X);

        int max = 1;
        for (int i = 2; i <= MAX_ROOT; i++) {
            for (int j = 1; j <= 9; j++) {
                if ((int)Math.pow(i, j) > X) {
                    break;
                }
                max = Math.max((int)Math.pow(i, j), max);
            }
        }
        System.out.println(max);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    static int X;

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

        solve();
    }

    static void solve() {
        int MAX_ROOT = (int)Math.sqrt(X);

        int max = 1;
        for (int i = 2; i <= MAX_ROOT; i++) {
            for (int j = 1; j <= 9; j++) {
                if ((int)Math.pow(i, j) > X) {
                    break;
                }
                max = Math.max((int)Math.pow(i, j), max);
            }
        }
        System.out.println(max);
    }
} Main static int X; X public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        X = sc.nextInt();

        solve();
    } main {
        Scanner sc = new Scanner(System.in);
        X = sc.nextInt();

        solve();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) X = sc.nextInt() X sc.nextInt() sc.nextInt sc solve() solve String[] args args static void solve() {
        int MAX_ROOT = (int)Math.sqrt(X);

        int max = 1;
        for (int i = 2; i <= MAX_ROOT; i++) {
            for (int j = 1; j <= 9; j++) {
                if ((int)Math.pow(i, j) > X) {
                    break;
                }
                max = Math.max((int)Math.pow(i, j), max);
            }
        }
        System.out.println(max);
    } solve {
        int MAX_ROOT = (int)Math.sqrt(X);

        int max = 1;
        for (int i = 2; i <= MAX_ROOT; i++) {
            for (int j = 1; j <= 9; j++) {
                if ((int)Math.pow(i, j) > X) {
                    break;
                }
                max = Math.max((int)Math.pow(i, j), max);
            }
        }
        System.out.println(max);
    } int MAX_ROOT = (int)Math.sqrt(X); MAX_ROOT (int)Math.sqrt(X) Math.sqrt Math X int max = 1; max 1 for (int i = 2; i <= MAX_ROOT; i++) {
            for (int j = 1; j <= 9; j++) {
                if ((int)Math.pow(i, j) > X) {
                    break;
                }
                max = Math.max((int)Math.pow(i, j), max);
            }
        } int i = 2; int i = 2; i 2 i <= MAX_ROOT i MAX_ROOT i++ i++ i {
            for (int j = 1; j <= 9; j++) {
                if ((int)Math.pow(i, j) > X) {
                    break;
                }
                max = Math.max((int)Math.pow(i, j), max);
            }
        } {
            for (int j = 1; j <= 9; j++) {
                if ((int)Math.pow(i, j) > X) {
                    break;
                }
                max = Math.max((int)Math.pow(i, j), max);
            }
        } for (int j = 1; j <= 9; j++) {
                if ((int)Math.pow(i, j) > X) {
                    break;
                }
                max = Math.max((int)Math.pow(i, j), max);
            } int j = 1; int j = 1; j 1 j <= 9 j 9 j++ j++ j {
                if ((int)Math.pow(i, j) > X) {
                    break;
                }
                max = Math.max((int)Math.pow(i, j), max);
            } {
                if ((int)Math.pow(i, j) > X) {
                    break;
                }
                max = Math.max((int)Math.pow(i, j), max);
            } if ((int)Math.pow(i, j) > X) {
                    break;
                } (int)Math.pow(i, j) > X (int)Math.pow(i, j) Math.pow Math i j X {
                    break;
                } break; max = Math.max((int)Math.pow(i, j), max) max Math.max((int)Math.pow(i, j), max) Math.max Math (int)Math.pow(i, j) Math.pow Math i j max System.out.println(max) System.out.println System.out System System.out max public class Main {

    static int X;

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

        solve();
    }

    static void solve() {
        int MAX_ROOT = (int)Math.sqrt(X);

        int max = 1;
        for (int i = 2; i <= MAX_ROOT; i++) {
            for (int j = 1; j <= 9; j++) {
                if ((int)Math.pow(i, j) > X) {
                    break;
                }
                max = Math.max((int)Math.pow(i, j), max);
            }
        }
        System.out.println(max);
    }
} public class Main {

    static int X;

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

        solve();
    }

    static void solve() {
        int MAX_ROOT = (int)Math.sqrt(X);

        int max = 1;
        for (int i = 2; i <= MAX_ROOT; i++) {
            for (int j = 1; j <= 9; j++) {
                if ((int)Math.pow(i, j) > X) {
                    break;
                }
                max = Math.max((int)Math.pow(i, j), max);
            }
        }
        System.out.println(max);
    }
} Main
import java.util.Scanner;

public class Main {

    static int X;

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

        solve();
    }

    static void solve() {
        int MAX_ROOT = (int)Math.sqrt(X);

        int max = 1;
        for (int i = 2; i <= MAX_ROOT; i++) {
            for (int j = 1; j <= 9; j++) {
                if ((int)Math.pow(i, j) > X) {
                    break;
                }
                max = Math.max((int)Math.pow(i, j), max);
            }
        }
        System.out.println(max);
    }
}
