import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();

        Set<Integer> set = new HashSet<Integer>();
        for (int i = 2; i * i <= X; ++i) set.add(i);

        int max = 1;
        for (Integer i : set) {
            for (int j = i * i; j <= X; j *= i) {
                max = Math.max(max, j);
            }
        }

        System.out.println(max);

        return;
    }

} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
} Main public static void main(String[] args) {
        new Solver().run();
    } main {
        new Solver().run();
    } new Solver().run() new Solver().run new Solver() String[] args args class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();

        Set<Integer> set = new HashSet<Integer>();
        for (int i = 2; i * i <= X; ++i) set.add(i);

        int max = 1;
        for (Integer i : set) {
            for (int j = i * i; j <= X; j *= i) {
                max = Math.max(max, j);
            }
        }

        System.out.println(max);

        return;
    }

} Solver public void run() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();

        Set<Integer> set = new HashSet<Integer>();
        for (int i = 2; i * i <= X; ++i) set.add(i);

        int max = 1;
        for (Integer i : set) {
            for (int j = i * i; j <= X; j *= i) {
                max = Math.max(max, j);
            }
        }

        System.out.println(max);

        return;
    } run {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();

        Set<Integer> set = new HashSet<Integer>();
        for (int i = 2; i * i <= X; ++i) set.add(i);

        int max = 1;
        for (Integer i : set) {
            for (int j = i * i; j <= X; j *= i) {
                max = Math.max(max, j);
            }
        }

        System.out.println(max);

        return;
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc Set<Integer> set = new HashSet<Integer>(); set new HashSet<Integer>() for (int i = 2; i * i <= X; ++i) set.add(i); int i = 2; int i = 2; i 2 i * i <= X i * i i i X ++i ++i i set.add(i); set.add(i) set.add set i int max = 1; max 1 for (Integer i : set) {
            for (int j = i * i; j <= X; j *= i) {
                max = Math.max(max, j);
            }
        } Integer i set {
            for (int j = i * i; j <= X; j *= i) {
                max = Math.max(max, j);
            }
        } {
            for (int j = i * i; j <= X; j *= i) {
                max = Math.max(max, j);
            }
        } for (int j = i * i; j <= X; j *= i) {
                max = Math.max(max, j);
            } int j = i * i; int j = i * i; j i * i i i j <= X j X j *= i j *= i j i {
                max = Math.max(max, j);
            } {
                max = Math.max(max, j);
            } max = Math.max(max, j) max Math.max(max, j) Math.max Math max j System.out.println(max) System.out.println System.out System System.out max return;
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();

        Set<Integer> set = new HashSet<Integer>();
        for (int i = 2; i * i <= X; ++i) set.add(i);

        int max = 1;
        for (Integer i : set) {
            for (int j = i * i; j <= X; j *= i) {
                max = Math.max(max, j);
            }
        }

        System.out.println(max);

        return;
    }

}
