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
 *
 * @author Kenji
 */
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);
        ABC097B solver = new ABC097B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC097B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            boolean[] b = new boolean[X + 1];
            b[1] = true;
            for (int c = 2; c <= X; c++) {
                int v = c * c;
                while (v <= X) {
                    b[v] = true;
                    v *= c;
                }
            }
            for (int i = X; i >= 1; i--) {
                if (b[i]) {
                    out.println(i);
                    return;
                }
            }
            return;
        }

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

    static class ABC097B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            boolean[] b = new boolean[X + 1];
            b[1] = true;
            for (int c = 2; c <= X; c++) {
                int v = c * c;
                while (v <= X) {
                    b[v] = true;
                    v *= c;
                }
            }
            for (int i = X; i >= 1; i--) {
                if (b[i]) {
                    out.println(i);
                    return;
                }
            }
            return;
        }

    }
} 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);
        ABC097B solver = new ABC097B();
        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);
        ABC097B solver = new ABC097B();
        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) ABC097B solver = new ABC097B(); solver new ABC097B() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class ABC097B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            boolean[] b = new boolean[X + 1];
            b[1] = true;
            for (int c = 2; c <= X; c++) {
                int v = c * c;
                while (v <= X) {
                    b[v] = true;
                    v *= c;
                }
            }
            for (int i = X; i >= 1; i--) {
                if (b[i]) {
                    out.println(i);
                    return;
                }
            }
            return;
        }

    } ABC097B public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            boolean[] b = new boolean[X + 1];
            b[1] = true;
            for (int c = 2; c <= X; c++) {
                int v = c * c;
                while (v <= X) {
                    b[v] = true;
                    v *= c;
                }
            }
            for (int i = X; i >= 1; i--) {
                if (b[i]) {
                    out.println(i);
                    return;
                }
            }
            return;
        } solve {
            int X = in.nextInt();
            boolean[] b = new boolean[X + 1];
            b[1] = true;
            for (int c = 2; c <= X; c++) {
                int v = c * c;
                while (v <= X) {
                    b[v] = true;
                    v *= c;
                }
            }
            for (int i = X; i >= 1; i--) {
                if (b[i]) {
                    out.println(i);
                    return;
                }
            }
            return;
        } int X = in.nextInt(); X in.nextInt() in.nextInt in boolean[] b = new boolean[X + 1]; b new boolean[X + 1] X + 1 X 1 b[1] = true b[1] b 1 true for (int c = 2; c <= X; c++) {
                int v = c * c;
                while (v <= X) {
                    b[v] = true;
                    v *= c;
                }
            } int c = 2; int c = 2; c 2 c <= X c X c++ c++ c {
                int v = c * c;
                while (v <= X) {
                    b[v] = true;
                    v *= c;
                }
            } {
                int v = c * c;
                while (v <= X) {
                    b[v] = true;
                    v *= c;
                }
            } int v = c * c; v c * c c c while (v <= X) {
                    b[v] = true;
                    v *= c;
                } v <= X v X {
                    b[v] = true;
                    v *= c;
                } b[v] = true b[v] b v true v *= c v c for (int i = X; i >= 1; i--) {
                if (b[i]) {
                    out.println(i);
                    return;
                }
            } int i = X; int i = X; i X i >= 1 i 1 i-- i-- i {
                if (b[i]) {
                    out.println(i);
                    return;
                }
            } {
                if (b[i]) {
                    out.println(i);
                    return;
                }
            } if (b[i]) {
                    out.println(i);
                    return;
                } b[i] b i {
                    out.println(i);
                    return;
                } out.println(i) out.println out i return; return; 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);
        ABC097B solver = new ABC097B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC097B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            boolean[] b = new boolean[X + 1];
            b[1] = true;
            for (int c = 2; c <= X; c++) {
                int v = c * c;
                while (v <= X) {
                    b[v] = true;
                    v *= c;
                }
            }
            for (int i = X; i >= 1; i--) {
                if (b[i]) {
                    out.println(i);
                    return;
                }
            }
            return;
        }

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

    static class ABC097B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            boolean[] b = new boolean[X + 1];
            b[1] = true;
            for (int c = 2; c <= X; c++) {
                int v = c * c;
                while (v <= X) {
                    b[v] = true;
                    v *= c;
                }
            }
            for (int i = X; i >= 1; i--) {
                if (b[i]) {
                    out.println(i);
                    return;
                }
            }
            return;
        }

    }
} 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
 *
 * @author Kenji
 */
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);
        ABC097B solver = new ABC097B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC097B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            boolean[] b = new boolean[X + 1];
            b[1] = true;
            for (int c = 2; c <= X; c++) {
                int v = c * c;
                while (v <= X) {
                    b[v] = true;
                    v *= c;
                }
            }
            for (int i = X; i >= 1; i--) {
                if (b[i]) {
                    out.println(i);
                    return;
                }
            }
            return;
        }

    }
}

