import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int X = in.i();
        int max = 1;
        for (int b = 2; b * b <= X; b++) {
            for (int p = 2; ; p++) {
                int t = pow(b, p);
                if (X < t) {
                    break;
                } else if (max < t) {
                    max = t;
                }
            }
        }
        out.println(max);
    }

    static int pow(int a, int b) {
        int c = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                c *= a;
            }
            a *= a;
            b >>= 1;
        }
        return c;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
} import java.io.*; io.* java import java.util.*; util.* java import static java.lang.System.out; import static java.lang.System.out; import static java.lang.System.out; public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int X = in.i();
        int max = 1;
        for (int b = 2; b * b <= X; b++) {
            for (int p = 2; ; p++) {
                int t = pow(b, p);
                if (X < t) {
                    break;
                } else if (max < t) {
                    max = t;
                }
            }
        }
        out.println(max);
    }

    static int pow(int a, int b) {
        int c = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                c *= a;
            }
            a *= a;
            b >>= 1;
        }
        return c;
    }
} Main static MyReader in = new MyReader(); in new MyReader() public static void main(String[] args) {
        int X = in.i();
        int max = 1;
        for (int b = 2; b * b <= X; b++) {
            for (int p = 2; ; p++) {
                int t = pow(b, p);
                if (X < t) {
                    break;
                } else if (max < t) {
                    max = t;
                }
            }
        }
        out.println(max);
    } main {
        int X = in.i();
        int max = 1;
        for (int b = 2; b * b <= X; b++) {
            for (int p = 2; ; p++) {
                int t = pow(b, p);
                if (X < t) {
                    break;
                } else if (max < t) {
                    max = t;
                }
            }
        }
        out.println(max);
    } int X = in.i(); X in.i() in.i in int max = 1; max 1 for (int b = 2; b * b <= X; b++) {
            for (int p = 2; ; p++) {
                int t = pow(b, p);
                if (X < t) {
                    break;
                } else if (max < t) {
                    max = t;
                }
            }
        } int b = 2; int b = 2; b 2 b * b <= X b * b b b X b++ b++ b {
            for (int p = 2; ; p++) {
                int t = pow(b, p);
                if (X < t) {
                    break;
                } else if (max < t) {
                    max = t;
                }
            }
        } {
            for (int p = 2; ; p++) {
                int t = pow(b, p);
                if (X < t) {
                    break;
                } else if (max < t) {
                    max = t;
                }
            }
        } for (int p = 2; ; p++) {
                int t = pow(b, p);
                if (X < t) {
                    break;
                } else if (max < t) {
                    max = t;
                }
            } int p = 2; int p = 2; p 2 p++ p++ p {
                int t = pow(b, p);
                if (X < t) {
                    break;
                } else if (max < t) {
                    max = t;
                }
            } {
                int t = pow(b, p);
                if (X < t) {
                    break;
                } else if (max < t) {
                    max = t;
                }
            } int t = pow(b, p); t pow(b, p) pow b p if (X < t) {
                    break;
                } else if (max < t) {
                    max = t;
                } X < t X t {
                    break;
                } break; if (max < t) {
                    max = t;
                } max < t max t {
                    max = t;
                } max = t max t out.println(max) out.println out max String[] args args static int pow(int a, int b) {
        int c = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                c *= a;
            }
            a *= a;
            b >>= 1;
        }
        return c;
    } pow {
        int c = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                c *= a;
            }
            a *= a;
            b >>= 1;
        }
        return c;
    } int c = 1; c 1 while (b > 0) {
            if ((b & 1) == 1) {
                c *= a;
            }
            a *= a;
            b >>= 1;
        } b > 0 b 0 {
            if ((b & 1) == 1) {
                c *= a;
            }
            a *= a;
            b >>= 1;
        } if ((b & 1) == 1) {
                c *= a;
            } (b & 1) == 1 (b & 1) b 1 1 {
                c *= a;
            } c *= a c a a *= a a a b >>= 1 b 1 return c; c int a a int b b class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
} MyReader char[] cbuf = new char[1024]; cbuf new char[1024] 1024 int head = 0; head 0 int tail = 0; tail 0 MyReader() {
        super(new InputStreamReader(System.in));
    } MyReader {
        super(new InputStreamReader(System.in));
    } super(new InputStreamReader(System.in)) super new InputStreamReader(System.in) char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    } next {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    } if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        } head == tail head tail {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        } try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } IOException e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                tail = super.read(cbuf, 0, cbuf.length);
            } tail = super.read(cbuf, 0, cbuf.length) tail super.read(cbuf, 0, cbuf.length) super.read super cbuf 0 cbuf.length cbuf cbuf.length head = 0 head 0 return cbuf[head++]; cbuf[head++] cbuf head++ head void back() {
        head--;
    } back {
        head--;
    } head-- head boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    } minus {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    } boolean minus; minus while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        } true {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        } char c = next(); c next() next if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            } !isDelimiter(c) isDelimiter(c) isDelimiter c {
                if (!(minus = c == '-')) back();
                return minus;
            } if (!(minus = c == '-')) back(); !(minus = c == '-') (minus = c == '-') minus c == '-' c '-' back() back return minus; minus void skip() {
        while (isDelimiter(next()));
        back();
    } skip {
        while (isDelimiter(next()));
        back();
    } while (isDelimiter(next())); isDelimiter(next()) isDelimiter next() next back() back char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    } s {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    } char[] cbuf = new char[N]; cbuf new char[N] N read(cbuf, 0, N) read cbuf 0 N return cbuf; cbuf int N N public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    } read {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    } skip() skip int i; i for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        } i = 0; i = 0 i 0 i < cbuf.length i cbuf.length cbuf cbuf.length i++ i++ i {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        } {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        } char c = next(); c next() next if (isDelimiter(c)) {
                break;
            } isDelimiter(c) isDelimiter c {
                break;
            } break; cbuf[i] = c cbuf[i] cbuf i c return i; i char[] cbuf cbuf int off off int len len boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    } isDelimiter {
        return c == ' ' || c == '\n' || c == '\r';
    } return c == ' ' || c == '\n' || c == '\r'; c == ' ' || c == '\n' || c == '\r' c == ' ' || c == '\n' || c == '\r' c == ' ' c ' ' c == '\n' c '\n' c == '\r' c '\r' char c c int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    } i {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    } boolean minus = minus(); minus minus() minus int n = 0; n 0 while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        } true {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        } int k = next() - '0'; k next() - '0' next() next '0' if (k < 0 || 9 < k) break; k < 0 || 9 < k k < 0 k 0 9 < k 9 k break; n = 10 * n + k n 10 * n + k 10 * n 10 n k return minus ? -n : n; minus ? -n : n minus -n n n int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    } ii {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    } int[] a = new int[N]; a new int[N] N for (int j = 0; j < a.length; j++) a[j] = i(); int j = 0; int j = 0; j 0 j < a.length j a.length a a.length j++ j++ j a[j] = i(); a[j] = i() a[j] a j i() i return a; a final int N N long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    } l {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    } boolean minus = minus(); minus minus() minus long n = 0; n 0 while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        } true {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        } int k = next() - '0'; k next() - '0' next() next '0' if (k < 0 || 9 < k) break; k < 0 || 9 < k k < 0 k 0 9 < k 9 k break; n = 10 * n + k n 10 * n + k 10 * n 10 n k return minus ? -n : n; minus ? -n : n minus -n n n BufferedReader public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int X = in.i();
        int max = 1;
        for (int b = 2; b * b <= X; b++) {
            for (int p = 2; ; p++) {
                int t = pow(b, p);
                if (X < t) {
                    break;
                } else if (max < t) {
                    max = t;
                }
            }
        }
        out.println(max);
    }

    static int pow(int a, int b) {
        int c = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                c *= a;
            }
            a *= a;
            b >>= 1;
        }
        return c;
    }
} public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int X = in.i();
        int max = 1;
        for (int b = 2; b * b <= X; b++) {
            for (int p = 2; ; p++) {
                int t = pow(b, p);
                if (X < t) {
                    break;
                } else if (max < t) {
                    max = t;
                }
            }
        }
        out.println(max);
    }

    static int pow(int a, int b) {
        int c = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                c *= a;
            }
            a *= a;
            b >>= 1;
        }
        return c;
    }
} Main
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int X = in.i();
        int max = 1;
        for (int b = 2; b * b <= X; b++) {
            for (int p = 2; ; p++) {
                int t = pow(b, p);
                if (X < t) {
                    break;
                } else if (max < t) {
                    max = t;
                }
            }
        }
        out.println(max);
    }

    static int pow(int a, int b) {
        int c = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                c *= a;
            }
            a *= a;
            b >>= 1;
        }
        return c;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}
