import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        for (int i = 2; i <= a; i++) {
            int tmp = 0;
            int count = 2;
            while(tmp <= a) {
                tmp = (int) Math.pow(i, count);
                if(tmp <= a) {
                    count++;
                    list.add(tmp);
                }
            }
        }
        System.out.println(Collections.max(list));
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        for (int i = 2; i <= a; i++) {
            int tmp = 0;
            int count = 2;
            while(tmp <= a) {
                tmp = (int) Math.pow(i, count);
                if(tmp <= a) {
                    count++;
                    list.add(tmp);
                }
            }
        }
        System.out.println(Collections.max(list));
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        for (int i = 2; i <= a; i++) {
            int tmp = 0;
            int count = 2;
            while(tmp <= a) {
                tmp = (int) Math.pow(i, count);
                if(tmp <= a) {
                    count++;
                    list.add(tmp);
                }
            }
        }
        System.out.println(Collections.max(list));
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        for (int i = 2; i <= a; i++) {
            int tmp = 0;
            int count = 2;
            while(tmp <= a) {
                tmp = (int) Math.pow(i, count);
                if(tmp <= a) {
                    count++;
                    list.add(tmp);
                }
            }
        }
        System.out.println(Collections.max(list));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc ArrayList<Integer> list = new ArrayList<>(); list new ArrayList<>() list.add(1) list.add list 1 for (int i = 2; i <= a; i++) {
            int tmp = 0;
            int count = 2;
            while(tmp <= a) {
                tmp = (int) Math.pow(i, count);
                if(tmp <= a) {
                    count++;
                    list.add(tmp);
                }
            }
        } int i = 2; int i = 2; i 2 i <= a i a i++ i++ i {
            int tmp = 0;
            int count = 2;
            while(tmp <= a) {
                tmp = (int) Math.pow(i, count);
                if(tmp <= a) {
                    count++;
                    list.add(tmp);
                }
            }
        } {
            int tmp = 0;
            int count = 2;
            while(tmp <= a) {
                tmp = (int) Math.pow(i, count);
                if(tmp <= a) {
                    count++;
                    list.add(tmp);
                }
            }
        } int tmp = 0; tmp 0 int count = 2; count 2 while(tmp <= a) {
                tmp = (int) Math.pow(i, count);
                if(tmp <= a) {
                    count++;
                    list.add(tmp);
                }
            } tmp <= a tmp a {
                tmp = (int) Math.pow(i, count);
                if(tmp <= a) {
                    count++;
                    list.add(tmp);
                }
            } tmp = (int) Math.pow(i, count) tmp (int) Math.pow(i, count) Math.pow Math i count if(tmp <= a) {
                    count++;
                    list.add(tmp);
                } tmp <= a tmp a {
                    count++;
                    list.add(tmp);
                } count++ count list.add(tmp) list.add list tmp System.out.println(Collections.max(list)) System.out.println System.out System System.out Collections.max(list) Collections.max Collections list String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        for (int i = 2; i <= a; i++) {
            int tmp = 0;
            int count = 2;
            while(tmp <= a) {
                tmp = (int) Math.pow(i, count);
                if(tmp <= a) {
                    count++;
                    list.add(tmp);
                }
            }
        }
        System.out.println(Collections.max(list));
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        for (int i = 2; i <= a; i++) {
            int tmp = 0;
            int count = 2;
            while(tmp <= a) {
                tmp = (int) Math.pow(i, count);
                if(tmp <= a) {
                    count++;
                    list.add(tmp);
                }
            }
        }
        System.out.println(Collections.max(list));
    }
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        for (int i = 2; i <= a; i++) {
            int tmp = 0;
            int count = 2;
            while(tmp <= a) {
                tmp = (int) Math.pow(i, count);
                if(tmp <= a) {
                    count++;
                    list.add(tmp);
                }
            }
        }
        System.out.println(Collections.max(list));
    }
}