import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int ans = 1;
        lavel:
        for (int i = 2; i < X; i++) {
            for (int j = 2;; j++) {
                if ((int) Math.pow(i, j) >X) {
                    continue lavel;
                } else if (ans < (int) Math.pow(i, j)) {
                    ans = (int) Math.pow(i, j);
                }
            }
        }
        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int ans = 1;
        lavel:
        for (int i = 2; i < X; i++) {
            for (int j = 2;; j++) {
                if ((int) Math.pow(i, j) >X) {
                    continue lavel;
                } else if (ans < (int) Math.pow(i, j)) {
                    ans = (int) Math.pow(i, j);
                }
            }
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        new Main().solve();
    } main {
        new Main().solve();
    } new Main().solve() new Main().solve new Main() String[] args args void solve() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int ans = 1;
        lavel:
        for (int i = 2; i < X; i++) {
            for (int j = 2;; j++) {
                if ((int) Math.pow(i, j) >X) {
                    continue lavel;
                } else if (ans < (int) Math.pow(i, j)) {
                    ans = (int) Math.pow(i, j);
                }
            }
        }
        System.out.println(ans);
    } solve {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int ans = 1;
        lavel:
        for (int i = 2; i < X; i++) {
            for (int j = 2;; j++) {
                if ((int) Math.pow(i, j) >X) {
                    continue lavel;
                } else if (ans < (int) Math.pow(i, j)) {
                    ans = (int) Math.pow(i, j);
                }
            }
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc int ans = 1; ans 1 System.out.println(ans) System.out.println System.out System System.out ans public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int ans = 1;
        lavel:
        for (int i = 2; i < X; i++) {
            for (int j = 2;; j++) {
                if ((int) Math.pow(i, j) >X) {
                    continue lavel;
                } else if (ans < (int) Math.pow(i, j)) {
                    ans = (int) Math.pow(i, j);
                }
            }
        }
        System.out.println(ans);
    }
} public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int ans = 1;
        lavel:
        for (int i = 2; i < X; i++) {
            for (int j = 2;; j++) {
                if ((int) Math.pow(i, j) >X) {
                    continue lavel;
                } else if (ans < (int) Math.pow(i, j)) {
                    ans = (int) Math.pow(i, j);
                }
            }
        }
        System.out.println(ans);
    }
} Main
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int ans = 1;
        lavel:
        for (int i = 2; i < X; i++) {
            for (int j = 2;; j++) {
                if ((int) Math.pow(i, j) >X) {
                    continue lavel;
                } else if (ans < (int) Math.pow(i, j)) {
                    ans = (int) Math.pow(i, j);
                }
            }
        }
        System.out.println(ans);
    }
}