import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int ret = 1;
        for (int i = 2; i < X; i++) {
            int a = i;
            while((a * i) <= X) {
                a *= i;
            }
            if ( a != i && ret < a ) {
                ret = a;
            }
        }
        System.out.println(ret);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int ret = 1;
        for (int i = 2; i < X; i++) {
            int a = i;
            while((a * i) <= X) {
                a *= i;
            }
            if ( a != i && ret < a ) {
                ret = a;
            }
        }
        System.out.println(ret);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int ret = 1;
        for (int i = 2; i < X; i++) {
            int a = i;
            while((a * i) <= X) {
                a *= i;
            }
            if ( a != i && ret < a ) {
                ret = a;
            }
        }
        System.out.println(ret);
    } main {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int ret = 1;
        for (int i = 2; i < X; i++) {
            int a = i;
            while((a * i) <= X) {
                a *= i;
            }
            if ( a != i && ret < a ) {
                ret = a;
            }
        }
        System.out.println(ret);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int X = scanner.nextInt(); X scanner.nextInt() scanner.nextInt scanner int ret = 1; ret 1 for (int i = 2; i < X; i++) {
            int a = i;
            while((a * i) <= X) {
                a *= i;
            }
            if ( a != i && ret < a ) {
                ret = a;
            }
        } int i = 2; int i = 2; i 2 i < X i X i++ i++ i {
            int a = i;
            while((a * i) <= X) {
                a *= i;
            }
            if ( a != i && ret < a ) {
                ret = a;
            }
        } {
            int a = i;
            while((a * i) <= X) {
                a *= i;
            }
            if ( a != i && ret < a ) {
                ret = a;
            }
        } int a = i; a i while((a * i) <= X) {
                a *= i;
            } (a * i) <= X (a * i) a i X {
                a *= i;
            } a *= i a i if ( a != i && ret < a ) {
                ret = a;
            } a != i && ret < a a != i a i ret < a ret a {
                ret = a;
            } ret = a ret a System.out.println(ret) System.out.println System.out System System.out ret String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int ret = 1;
        for (int i = 2; i < X; i++) {
            int a = i;
            while((a * i) <= X) {
                a *= i;
            }
            if ( a != i && ret < a ) {
                ret = a;
            }
        }
        System.out.println(ret);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int ret = 1;
        for (int i = 2; i < X; i++) {
            int a = i;
            while((a * i) <= X) {
                a *= i;
            }
            if ( a != i && ret < a ) {
                ret = a;
            }
        }
        System.out.println(ret);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int ret = 1;
        for (int i = 2; i < X; i++) {
            int a = i;
            while((a * i) <= X) {
                a *= i;
            }
            if ( a != i && ret < a ) {
                ret = a;
            }
        }
        System.out.println(ret);
    }
}
