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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int x = Integer.parseInt(in.next());

            long max = Integer.MIN_VALUE;
            long pw = 0;
            if (x == 1) {
                out.println(1);
                return;
            }
            for (int i = 31; i >= 2; --i) {
                for (int j = 10; j >= 2; --j) {
                    pw = (long) Math.pow(i, j);
                    if (pw <= x) {
                        max = Math.max(pw, max);
                    }
                }
            }
            out.println(max);

        }

    }
}
 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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int x = Integer.parseInt(in.next());

            long max = Integer.MIN_VALUE;
            long pw = 0;
            if (x == 1) {
                out.println(1);
                return;
            }
            for (int i = 31; i >= 2; --i) {
                for (int j = 10; j >= 2; --j) {
                    pw = (long) Math.pow(i, j);
                    if (pw <= x) {
                        max = Math.max(pw, max);
                    }
                }
            }
            out.println(max);

        }

    }
} 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);
        B solver = new 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);
        B solver = new 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) B solver = new B(); solver new B() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int x = Integer.parseInt(in.next());

            long max = Integer.MIN_VALUE;
            long pw = 0;
            if (x == 1) {
                out.println(1);
                return;
            }
            for (int i = 31; i >= 2; --i) {
                for (int j = 10; j >= 2; --j) {
                    pw = (long) Math.pow(i, j);
                    if (pw <= x) {
                        max = Math.max(pw, max);
                    }
                }
            }
            out.println(max);

        }

    } B public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int x = Integer.parseInt(in.next());

            long max = Integer.MIN_VALUE;
            long pw = 0;
            if (x == 1) {
                out.println(1);
                return;
            }
            for (int i = 31; i >= 2; --i) {
                for (int j = 10; j >= 2; --j) {
                    pw = (long) Math.pow(i, j);
                    if (pw <= x) {
                        max = Math.max(pw, max);
                    }
                }
            }
            out.println(max);

        } solve {
            // 入力
            int x = Integer.parseInt(in.next());

            long max = Integer.MIN_VALUE;
            long pw = 0;
            if (x == 1) {
                out.println(1);
                return;
            }
            for (int i = 31; i >= 2; --i) {
                for (int j = 10; j >= 2; --j) {
                    pw = (long) Math.pow(i, j);
                    if (pw <= x) {
                        max = Math.max(pw, max);
                    }
                }
            }
            out.println(max);

        } int x = Integer.parseInt(in.next()); x Integer.parseInt(in.next()) Integer.parseInt Integer in.next() in.next in long max = Integer.MIN_VALUE; max Integer.MIN_VALUE Integer Integer.MIN_VALUE long pw = 0; pw 0 if (x == 1) {
                out.println(1);
                return;
            } x == 1 x 1 {
                out.println(1);
                return;
            } out.println(1) out.println out 1 return; for (int i = 31; i >= 2; --i) {
                for (int j = 10; j >= 2; --j) {
                    pw = (long) Math.pow(i, j);
                    if (pw <= x) {
                        max = Math.max(pw, max);
                    }
                }
            } int i = 31; int i = 31; i 31 i >= 2 i 2 --i --i i {
                for (int j = 10; j >= 2; --j) {
                    pw = (long) Math.pow(i, j);
                    if (pw <= x) {
                        max = Math.max(pw, max);
                    }
                }
            } {
                for (int j = 10; j >= 2; --j) {
                    pw = (long) Math.pow(i, j);
                    if (pw <= x) {
                        max = Math.max(pw, max);
                    }
                }
            } for (int j = 10; j >= 2; --j) {
                    pw = (long) Math.pow(i, j);
                    if (pw <= x) {
                        max = Math.max(pw, max);
                    }
                } int j = 10; int j = 10; j 10 j >= 2 j 2 --j --j j {
                    pw = (long) Math.pow(i, j);
                    if (pw <= x) {
                        max = Math.max(pw, max);
                    }
                } {
                    pw = (long) Math.pow(i, j);
                    if (pw <= x) {
                        max = Math.max(pw, max);
                    }
                } pw = (long) Math.pow(i, j) pw (long) Math.pow(i, j) Math.pow Math i j if (pw <= x) {
                        max = Math.max(pw, max);
                    } pw <= x pw x {
                        max = Math.max(pw, max);
                    } max = Math.max(pw, max) max Math.max(pw, max) Math.max Math pw max out.println(max) out.println out max 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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int x = Integer.parseInt(in.next());

            long max = Integer.MIN_VALUE;
            long pw = 0;
            if (x == 1) {
                out.println(1);
                return;
            }
            for (int i = 31; i >= 2; --i) {
                for (int j = 10; j >= 2; --j) {
                    pw = (long) Math.pow(i, j);
                    if (pw <= x) {
                        max = Math.max(pw, max);
                    }
                }
            }
            out.println(max);

        }

    }
} 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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int x = Integer.parseInt(in.next());

            long max = Integer.MIN_VALUE;
            long pw = 0;
            if (x == 1) {
                out.println(1);
                return;
            }
            for (int i = 31; i >= 2; --i) {
                for (int j = 10; j >= 2; --j) {
                    pw = (long) Math.pow(i, j);
                    if (pw <= x) {
                        max = Math.max(pw, max);
                    }
                }
            }
            out.println(max);

        }

    }
} 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);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int x = Integer.parseInt(in.next());

            long max = Integer.MIN_VALUE;
            long pw = 0;
            if (x == 1) {
                out.println(1);
                return;
            }
            for (int i = 31; i >= 2; --i) {
                for (int j = 10; j >= 2; --j) {
                    pw = (long) Math.pow(i, j);
                    if (pw <= x) {
                        max = Math.max(pw, max);
                    }
                }
            }
            out.println(max);

        }

    }
}

