import java.io.IOException;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {

        // long startTime = System.currentTimeMillis();

        Scanner scanner = new Scanner(System.in);

        int x = scanner.nextInt();

        scanner.close();

        System.out.println(calc(x));

        // System.out.println(System.currentTimeMillis() - startTime);
    }

    private static int calc(int x) {
        int s = (int) Math.sqrt(x);
        int max = 1;
        for (int i = 2; i <= s; i++) {
            int j = i;
            int k = 2;
            while (j <= x) {
                if (max < j) {
                    max = j;
                }
                j = (int) Math.pow(i, k);
                k++;
            }
        }

        return max;
    }
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) throws IOException {

        // long startTime = System.currentTimeMillis();

        Scanner scanner = new Scanner(System.in);

        int x = scanner.nextInt();

        scanner.close();

        System.out.println(calc(x));

        // System.out.println(System.currentTimeMillis() - startTime);
    }

    private static int calc(int x) {
        int s = (int) Math.sqrt(x);
        int max = 1;
        for (int i = 2; i <= s; i++) {
            int j = i;
            int k = 2;
            while (j <= x) {
                if (max < j) {
                    max = j;
                }
                j = (int) Math.pow(i, k);
                k++;
            }
        }

        return max;
    }
} Main public static void main(String[] args) throws IOException {

        // long startTime = System.currentTimeMillis();

        Scanner scanner = new Scanner(System.in);

        int x = scanner.nextInt();

        scanner.close();

        System.out.println(calc(x));

        // System.out.println(System.currentTimeMillis() - startTime);
    } main {

        // long startTime = System.currentTimeMillis();

        Scanner scanner = new Scanner(System.in);

        int x = scanner.nextInt();

        scanner.close();

        System.out.println(calc(x));

        // System.out.println(System.currentTimeMillis() - startTime);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int x = scanner.nextInt(); x scanner.nextInt() scanner.nextInt scanner scanner.close() scanner.close scanner System.out.println(calc(x)) System.out.println System.out System System.out calc(x) calc x String[] args args private static int calc(int x) {
        int s = (int) Math.sqrt(x);
        int max = 1;
        for (int i = 2; i <= s; i++) {
            int j = i;
            int k = 2;
            while (j <= x) {
                if (max < j) {
                    max = j;
                }
                j = (int) Math.pow(i, k);
                k++;
            }
        }

        return max;
    } calc {
        int s = (int) Math.sqrt(x);
        int max = 1;
        for (int i = 2; i <= s; i++) {
            int j = i;
            int k = 2;
            while (j <= x) {
                if (max < j) {
                    max = j;
                }
                j = (int) Math.pow(i, k);
                k++;
            }
        }

        return max;
    } int s = (int) Math.sqrt(x); s (int) Math.sqrt(x) Math.sqrt Math x int max = 1; max 1 for (int i = 2; i <= s; i++) {
            int j = i;
            int k = 2;
            while (j <= x) {
                if (max < j) {
                    max = j;
                }
                j = (int) Math.pow(i, k);
                k++;
            }
        } int i = 2; int i = 2; i 2 i <= s i s i++ i++ i {
            int j = i;
            int k = 2;
            while (j <= x) {
                if (max < j) {
                    max = j;
                }
                j = (int) Math.pow(i, k);
                k++;
            }
        } {
            int j = i;
            int k = 2;
            while (j <= x) {
                if (max < j) {
                    max = j;
                }
                j = (int) Math.pow(i, k);
                k++;
            }
        } int j = i; j i int k = 2; k 2 while (j <= x) {
                if (max < j) {
                    max = j;
                }
                j = (int) Math.pow(i, k);
                k++;
            } j <= x j x {
                if (max < j) {
                    max = j;
                }
                j = (int) Math.pow(i, k);
                k++;
            } if (max < j) {
                    max = j;
                } max < j max j {
                    max = j;
                } max = j max j j = (int) Math.pow(i, k) j (int) Math.pow(i, k) Math.pow Math i k k++ k return max; max int x x public class Main {

    public static void main(String[] args) throws IOException {

        // long startTime = System.currentTimeMillis();

        Scanner scanner = new Scanner(System.in);

        int x = scanner.nextInt();

        scanner.close();

        System.out.println(calc(x));

        // System.out.println(System.currentTimeMillis() - startTime);
    }

    private static int calc(int x) {
        int s = (int) Math.sqrt(x);
        int max = 1;
        for (int i = 2; i <= s; i++) {
            int j = i;
            int k = 2;
            while (j <= x) {
                if (max < j) {
                    max = j;
                }
                j = (int) Math.pow(i, k);
                k++;
            }
        }

        return max;
    }
} public class Main {

    public static void main(String[] args) throws IOException {

        // long startTime = System.currentTimeMillis();

        Scanner scanner = new Scanner(System.in);

        int x = scanner.nextInt();

        scanner.close();

        System.out.println(calc(x));

        // System.out.println(System.currentTimeMillis() - startTime);
    }

    private static int calc(int x) {
        int s = (int) Math.sqrt(x);
        int max = 1;
        for (int i = 2; i <= s; i++) {
            int j = i;
            int k = 2;
            while (j <= x) {
                if (max < j) {
                    max = j;
                }
                j = (int) Math.pow(i, k);
                k++;
            }
        }

        return max;
    }
} Main
import java.io.IOException;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {

        // long startTime = System.currentTimeMillis();

        Scanner scanner = new Scanner(System.in);

        int x = scanner.nextInt();

        scanner.close();

        System.out.println(calc(x));

        // System.out.println(System.currentTimeMillis() - startTime);
    }

    private static int calc(int x) {
        int s = (int) Math.sqrt(x);
        int max = 1;
        for (int i = 2; i <= s; i++) {
            int j = i;
            int k = 2;
            while (j <= x) {
                if (max < j) {
                    max = j;
                }
                j = (int) Math.pow(i, k);
                k++;
            }
        }

        return max;
    }
}
