import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int res = 1;
        for (int i = 2; i * i <= x; i++) {
            int p = i * i;
            while (p <= x) {
                res = Math.max(res, p);
                p *= i;
            } 
        }
        System.out.println(res);
        sc.close();
    }
} 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();
        int res = 1;
        for (int i = 2; i * i <= x; i++) {
            int p = i * i;
            while (p <= x) {
                res = Math.max(res, p);
                p *= i;
            } 
        }
        System.out.println(res);
        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int res = 1;
        for (int i = 2; i * i <= x; i++) {
            int p = i * i;
            while (p <= x) {
                res = Math.max(res, p);
                p *= i;
            } 
        }
        System.out.println(res);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int res = 1;
        for (int i = 2; i * i <= x; i++) {
            int p = i * i;
            while (p <= x) {
                res = Math.max(res, p);
                p *= i;
            } 
        }
        System.out.println(res);
        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int res = 1; res 1 for (int i = 2; i * i <= x; i++) {
            int p = i * i;
            while (p <= x) {
                res = Math.max(res, p);
                p *= i;
            } 
        } int i = 2; int i = 2; i 2 i * i <= x i * i i i x i++ i++ i {
            int p = i * i;
            while (p <= x) {
                res = Math.max(res, p);
                p *= i;
            } 
        } {
            int p = i * i;
            while (p <= x) {
                res = Math.max(res, p);
                p *= i;
            } 
        } int p = i * i; p i * i i i while (p <= x) {
                res = Math.max(res, p);
                p *= i;
            } p <= x p x {
                res = Math.max(res, p);
                p *= i;
            } res = Math.max(res, p) res Math.max(res, p) Math.max Math res p p *= i p i System.out.println(res) System.out.println System.out System System.out res sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int res = 1;
        for (int i = 2; i * i <= x; i++) {
            int p = i * i;
            while (p <= x) {
                res = Math.max(res, p);
                p *= i;
            } 
        }
        System.out.println(res);
        sc.close();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int res = 1;
        for (int i = 2; i * i <= x; i++) {
            int p = i * i;
            while (p <= x) {
                res = Math.max(res, p);
                p *= i;
            } 
        }
        System.out.println(res);
        sc.close();
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int res = 1;
        for (int i = 2; i * i <= x; i++) {
            int p = i * i;
            while (p <= x) {
                res = Math.max(res, p);
                p *= i;
            } 
        }
        System.out.println(res);
        sc.close();
    }
}