import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();

        System.out.println(solve(X));

        sc.close();
    }

    static int solve(int X) {
        int result = 1;
        for (int b = 2; b * b <= X; ++b) {
            int power = b * b;
            while (power * b <= X) {
                power *= b;
            }

            result = Math.max(result, power);
        }

        return result;
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();

        System.out.println(solve(X));

        sc.close();
    }

    static int solve(int X) {
        int result = 1;
        for (int b = 2; b * b <= X; ++b) {
            int power = b * b;
            while (power * b <= X) {
                power *= b;
            }

            result = Math.max(result, power);
        }

        return result;
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();

        System.out.println(solve(X));

        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();

        System.out.println(solve(X));

        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc System.out.println(solve(X)) System.out.println System.out System System.out solve(X) solve X sc.close() sc.close sc String[] args args static int solve(int X) {
        int result = 1;
        for (int b = 2; b * b <= X; ++b) {
            int power = b * b;
            while (power * b <= X) {
                power *= b;
            }

            result = Math.max(result, power);
        }

        return result;
    } solve {
        int result = 1;
        for (int b = 2; b * b <= X; ++b) {
            int power = b * b;
            while (power * b <= X) {
                power *= b;
            }

            result = Math.max(result, power);
        }

        return result;
    } int result = 1; result 1 for (int b = 2; b * b <= X; ++b) {
            int power = b * b;
            while (power * b <= X) {
                power *= b;
            }

            result = Math.max(result, power);
        } int b = 2; int b = 2; b 2 b * b <= X b * b b b X ++b ++b b {
            int power = b * b;
            while (power * b <= X) {
                power *= b;
            }

            result = Math.max(result, power);
        } {
            int power = b * b;
            while (power * b <= X) {
                power *= b;
            }

            result = Math.max(result, power);
        } int power = b * b; power b * b b b while (power * b <= X) {
                power *= b;
            } power * b <= X power * b power b X {
                power *= b;
            } power *= b power b result = Math.max(result, power) result Math.max(result, power) Math.max Math result power return result; result int X X public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();

        System.out.println(solve(X));

        sc.close();
    }

    static int solve(int X) {
        int result = 1;
        for (int b = 2; b * b <= X; ++b) {
            int power = b * b;
            while (power * b <= X) {
                power *= b;
            }

            result = Math.max(result, power);
        }

        return result;
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();

        System.out.println(solve(X));

        sc.close();
    }

    static int solve(int X) {
        int result = 1;
        for (int b = 2; b * b <= X; ++b) {
            int power = b * b;
            while (power * b <= X) {
                power *= b;
            }

            result = Math.max(result, power);
        }

        return result;
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();

        System.out.println(solve(X));

        sc.close();
    }

    static int solve(int X) {
        int result = 1;
        for (int b = 2; b * b <= X; ++b) {
            int power = b * b;
            while (power * b <= X) {
                power *= b;
            }

            result = Math.max(result, power);
        }

        return result;
    }
}