import java.security.cert.CollectionCertStoreParameters;
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int maxRoot = (int) Math.sqrt(1000);
        List<Integer> list = new ArrayList<>();
        list.add(1);
        for (int i = 2; i <= maxRoot; i++) {
            int num = i * i;
            while (num <= 1000) {
                list.add(num);
                num *= i;
            }
        }
        Collections.sort(list);

        int result = 0;
        for (int num : list) {
            if (x < num) {
                break;
            }
            result = num;
        }

        // 出力
        System.out.println(result);
    }
} import java.security.cert.CollectionCertStoreParameters; CollectionCertStoreParameters java.security.cert import java.util.*; util.* java public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int maxRoot = (int) Math.sqrt(1000);
        List<Integer> list = new ArrayList<>();
        list.add(1);
        for (int i = 2; i <= maxRoot; i++) {
            int num = i * i;
            while (num <= 1000) {
                list.add(num);
                num *= i;
            }
        }
        Collections.sort(list);

        int result = 0;
        for (int num : list) {
            if (x < num) {
                break;
            }
            result = num;
        }

        // 出力
        System.out.println(result);
    }
} Main public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int maxRoot = (int) Math.sqrt(1000);
        List<Integer> list = new ArrayList<>();
        list.add(1);
        for (int i = 2; i <= maxRoot; i++) {
            int num = i * i;
            while (num <= 1000) {
                list.add(num);
                num *= i;
            }
        }
        Collections.sort(list);

        int result = 0;
        for (int num : list) {
            if (x < num) {
                break;
            }
            result = num;
        }

        // 出力
        System.out.println(result);
    } main {

        // 入力
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int maxRoot = (int) Math.sqrt(1000);
        List<Integer> list = new ArrayList<>();
        list.add(1);
        for (int i = 2; i <= maxRoot; i++) {
            int num = i * i;
            while (num <= 1000) {
                list.add(num);
                num *= i;
            }
        }
        Collections.sort(list);

        int result = 0;
        for (int num : list) {
            if (x < num) {
                break;
            }
            result = num;
        }

        // 出力
        System.out.println(result);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = Integer.parseInt(sc.next()); x Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sc.close() sc.close sc int maxRoot = (int) Math.sqrt(1000); maxRoot (int) Math.sqrt(1000) Math.sqrt Math 1000 List<Integer> list = new ArrayList<>(); list new ArrayList<>() list.add(1) list.add list 1 for (int i = 2; i <= maxRoot; i++) {
            int num = i * i;
            while (num <= 1000) {
                list.add(num);
                num *= i;
            }
        } int i = 2; int i = 2; i 2 i <= maxRoot i maxRoot i++ i++ i {
            int num = i * i;
            while (num <= 1000) {
                list.add(num);
                num *= i;
            }
        } {
            int num = i * i;
            while (num <= 1000) {
                list.add(num);
                num *= i;
            }
        } int num = i * i; num i * i i i while (num <= 1000) {
                list.add(num);
                num *= i;
            } num <= 1000 num 1000 {
                list.add(num);
                num *= i;
            } list.add(num) list.add list num num *= i num i Collections.sort(list) Collections.sort Collections list int result = 0; result 0 for (int num : list) {
            if (x < num) {
                break;
            }
            result = num;
        } int num list {
            if (x < num) {
                break;
            }
            result = num;
        } {
            if (x < num) {
                break;
            }
            result = num;
        } if (x < num) {
                break;
            } x < num x num {
                break;
            } break; result = num result num System.out.println(result) System.out.println System.out System System.out result String args[] args public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int maxRoot = (int) Math.sqrt(1000);
        List<Integer> list = new ArrayList<>();
        list.add(1);
        for (int i = 2; i <= maxRoot; i++) {
            int num = i * i;
            while (num <= 1000) {
                list.add(num);
                num *= i;
            }
        }
        Collections.sort(list);

        int result = 0;
        for (int num : list) {
            if (x < num) {
                break;
            }
            result = num;
        }

        // 出力
        System.out.println(result);
    }
} public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int maxRoot = (int) Math.sqrt(1000);
        List<Integer> list = new ArrayList<>();
        list.add(1);
        for (int i = 2; i <= maxRoot; i++) {
            int num = i * i;
            while (num <= 1000) {
                list.add(num);
                num *= i;
            }
        }
        Collections.sort(list);

        int result = 0;
        for (int num : list) {
            if (x < num) {
                break;
            }
            result = num;
        }

        // 出力
        System.out.println(result);
    }
} Main
import java.security.cert.CollectionCertStoreParameters;
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        int maxRoot = (int) Math.sqrt(1000);
        List<Integer> list = new ArrayList<>();
        list.add(1);
        for (int i = 2; i <= maxRoot; i++) {
            int num = i * i;
            while (num <= 1000) {
                list.add(num);
                num *= i;
            }
        }
        Collections.sort(list);

        int result = 0;
        for (int num : list) {
            if (x < num) {
                break;
            }
            result = num;
        }

        // 出力
        System.out.println(result);
    }
}
