import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        sc.close();
        int ans = 0;
        int work = 0;

        for (int i = 1; i <= x; i++) {
            for (int j = 2; j < 10; j++) {
                work = (int) Math.pow(i, j);
                if (work <= x) {
                    ans = Math.max(ans, work);
                } else {
                    break;
                }
            }
        }

        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        sc.close();
        int ans = 0;
        int work = 0;

        for (int i = 1; i <= x; i++) {
            for (int j = 2; j < 10; j++) {
                work = (int) Math.pow(i, j);
                if (work <= x) {
                    ans = Math.max(ans, work);
                } else {
                    break;
                }
            }
        }

        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        sc.close();
        int ans = 0;
        int work = 0;

        for (int i = 1; i <= x; i++) {
            for (int j = 2; j < 10; j++) {
                work = (int) Math.pow(i, j);
                if (work <= x) {
                    ans = Math.max(ans, work);
                } else {
                    break;
                }
            }
        }

        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        sc.close();
        int ans = 0;
        int work = 0;

        for (int i = 1; i <= x; i++) {
            for (int j = 2; j < 10; j++) {
                work = (int) Math.pow(i, j);
                if (work <= x) {
                    ans = Math.max(ans, work);
                } else {
                    break;
                }
            }
        }

        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 sc.close() sc.close sc int ans = 0; ans 0 int work = 0; work 0 for (int i = 1; i <= x; i++) {
            for (int j = 2; j < 10; j++) {
                work = (int) Math.pow(i, j);
                if (work <= x) {
                    ans = Math.max(ans, work);
                } else {
                    break;
                }
            }
        } int i = 1; int i = 1; i 1 i <= x i x i++ i++ i {
            for (int j = 2; j < 10; j++) {
                work = (int) Math.pow(i, j);
                if (work <= x) {
                    ans = Math.max(ans, work);
                } else {
                    break;
                }
            }
        } {
            for (int j = 2; j < 10; j++) {
                work = (int) Math.pow(i, j);
                if (work <= x) {
                    ans = Math.max(ans, work);
                } else {
                    break;
                }
            }
        } for (int j = 2; j < 10; j++) {
                work = (int) Math.pow(i, j);
                if (work <= x) {
                    ans = Math.max(ans, work);
                } else {
                    break;
                }
            } int j = 2; int j = 2; j 2 j < 10 j 10 j++ j++ j {
                work = (int) Math.pow(i, j);
                if (work <= x) {
                    ans = Math.max(ans, work);
                } else {
                    break;
                }
            } {
                work = (int) Math.pow(i, j);
                if (work <= x) {
                    ans = Math.max(ans, work);
                } else {
                    break;
                }
            } work = (int) Math.pow(i, j) work (int) Math.pow(i, j) Math.pow Math i j if (work <= x) {
                    ans = Math.max(ans, work);
                } else {
                    break;
                } work <= x work x {
                    ans = Math.max(ans, work);
                } ans = Math.max(ans, work) ans Math.max(ans, work) Math.max Math ans work {
                    break;
                } break; System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        sc.close();
        int ans = 0;
        int work = 0;

        for (int i = 1; i <= x; i++) {
            for (int j = 2; j < 10; j++) {
                work = (int) Math.pow(i, j);
                if (work <= x) {
                    ans = Math.max(ans, work);
                } else {
                    break;
                }
            }
        }

        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        sc.close();
        int ans = 0;
        int work = 0;

        for (int i = 1; i <= x; i++) {
            for (int j = 2; j < 10; j++) {
                work = (int) Math.pow(i, j);
                if (work <= x) {
                    ans = Math.max(ans, work);
                } else {
                    break;
                }
            }
        }

        System.out.println(ans);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        sc.close();
        int ans = 0;
        int work = 0;

        for (int i = 1; i <= x; i++) {
            for (int j = 2; j < 10; j++) {
                work = (int) Math.pow(i, j);
                if (work <= x) {
                    ans = Math.max(ans, work);
                } else {
                    break;
                }
            }
        }

        System.out.println(ans);
    }
}