import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC097_B solver = new ABC097_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC097_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt();

            int ans = 1;
            for (int i = 2; i <= x; i++) {
                int p = 2;
                while (Math.pow(i, p) <= x) {
                    ans = (int) Math.max(ans, Math.pow(i, p));
                    p++;
                }
            }

            out.print(ans);
        }

    }
}
 import java.io.OutputStream; OutputStream java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC097_B solver = new ABC097_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC097_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt();

            int ans = 1;
            for (int i = 2; i <= x; i++) {
                int p = 2;
                while (Math.pow(i, p) <= x) {
                    ans = (int) Math.max(ans, Math.pow(i, p));
                    p++;
                }
            }

            out.print(ans);
        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC097_B solver = new ABC097_B();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC097_B solver = new ABC097_B();
        solver.solve(1, in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out Scanner in = new Scanner(inputStream); in new Scanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) ABC097_B solver = new ABC097_B(); solver new ABC097_B() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class ABC097_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt();

            int ans = 1;
            for (int i = 2; i <= x; i++) {
                int p = 2;
                while (Math.pow(i, p) <= x) {
                    ans = (int) Math.max(ans, Math.pow(i, p));
                    p++;
                }
            }

            out.print(ans);
        }

    } ABC097_B public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt();

            int ans = 1;
            for (int i = 2; i <= x; i++) {
                int p = 2;
                while (Math.pow(i, p) <= x) {
                    ans = (int) Math.max(ans, Math.pow(i, p));
                    p++;
                }
            }

            out.print(ans);
        } solve {
            int x = in.nextInt();

            int ans = 1;
            for (int i = 2; i <= x; i++) {
                int p = 2;
                while (Math.pow(i, p) <= x) {
                    ans = (int) Math.max(ans, Math.pow(i, p));
                    p++;
                }
            }

            out.print(ans);
        } int x = in.nextInt(); x in.nextInt() in.nextInt in int ans = 1; ans 1 for (int i = 2; i <= x; i++) {
                int p = 2;
                while (Math.pow(i, p) <= x) {
                    ans = (int) Math.max(ans, Math.pow(i, p));
                    p++;
                }
            } int i = 2; int i = 2; i 2 i <= x i x i++ i++ i {
                int p = 2;
                while (Math.pow(i, p) <= x) {
                    ans = (int) Math.max(ans, Math.pow(i, p));
                    p++;
                }
            } {
                int p = 2;
                while (Math.pow(i, p) <= x) {
                    ans = (int) Math.max(ans, Math.pow(i, p));
                    p++;
                }
            } int p = 2; p 2 while (Math.pow(i, p) <= x) {
                    ans = (int) Math.max(ans, Math.pow(i, p));
                    p++;
                } Math.pow(i, p) <= x Math.pow(i, p) Math.pow Math i p x {
                    ans = (int) Math.max(ans, Math.pow(i, p));
                    p++;
                } ans = (int) Math.max(ans, Math.pow(i, p)) ans (int) Math.max(ans, Math.pow(i, p)) Math.max Math ans Math.pow(i, p) Math.pow Math i p p++ p out.print(ans) out.print out ans int testNumber testNumber Scanner in in PrintWriter out out public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC097_B solver = new ABC097_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC097_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt();

            int ans = 1;
            for (int i = 2; i <= x; i++) {
                int p = 2;
                while (Math.pow(i, p) <= x) {
                    ans = (int) Math.max(ans, Math.pow(i, p));
                    p++;
                }
            }

            out.print(ans);
        }

    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC097_B solver = new ABC097_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC097_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt();

            int ans = 1;
            for (int i = 2; i <= x; i++) {
                int p = 2;
                while (Math.pow(i, p) <= x) {
                    ans = (int) Math.max(ans, Math.pow(i, p));
                    p++;
                }
            }

            out.print(ans);
        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC097_B solver = new ABC097_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC097_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt();

            int ans = 1;
            for (int i = 2; i <= x; i++) {
                int p = 2;
                while (Math.pow(i, p) <= x) {
                    ans = (int) Math.max(ans, Math.pow(i, p));
                    p++;
                }
            }

            out.print(ans);
        }

    }
}

