import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        ArrayList<Integer> nums = new ArrayList<Integer>();
        nums.add(1);
        for (int i = 2;i <= 31;++i){
            int k = i * i;
            while (k <= 1000){
                nums.add(k);
                k *= i;
            }
        }
        int max = 1;
        for (int i = 0;i < nums.size();++i){
            int o = nums.get(i);
            if(o <= x&&o > max){
                max = o;
            }
        }
        System.out.println(max);





    }

} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.HashMap; HashMap 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 x = sc.nextInt();
        ArrayList<Integer> nums = new ArrayList<Integer>();
        nums.add(1);
        for (int i = 2;i <= 31;++i){
            int k = i * i;
            while (k <= 1000){
                nums.add(k);
                k *= i;
            }
        }
        int max = 1;
        for (int i = 0;i < nums.size();++i){
            int o = nums.get(i);
            if(o <= x&&o > max){
                max = o;
            }
        }
        System.out.println(max);





    }

} Main public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        ArrayList<Integer> nums = new ArrayList<Integer>();
        nums.add(1);
        for (int i = 2;i <= 31;++i){
            int k = i * i;
            while (k <= 1000){
                nums.add(k);
                k *= i;
            }
        }
        int max = 1;
        for (int i = 0;i < nums.size();++i){
            int o = nums.get(i);
            if(o <= x&&o > max){
                max = o;
            }
        }
        System.out.println(max);





    } main {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        ArrayList<Integer> nums = new ArrayList<Integer>();
        nums.add(1);
        for (int i = 2;i <= 31;++i){
            int k = i * i;
            while (k <= 1000){
                nums.add(k);
                k *= i;
            }
        }
        int max = 1;
        for (int i = 0;i < nums.size();++i){
            int o = nums.get(i);
            if(o <= x&&o > max){
                max = o;
            }
        }
        System.out.println(max);





    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc ArrayList<Integer> nums = new ArrayList<Integer>(); nums new ArrayList<Integer>() nums.add(1) nums.add nums 1 for (int i = 2;i <= 31;++i){
            int k = i * i;
            while (k <= 1000){
                nums.add(k);
                k *= i;
            }
        } int i = 2; int i = 2; i 2 i <= 31 i 31 ++i ++i i {
            int k = i * i;
            while (k <= 1000){
                nums.add(k);
                k *= i;
            }
        } {
            int k = i * i;
            while (k <= 1000){
                nums.add(k);
                k *= i;
            }
        } int k = i * i; k i * i i i while (k <= 1000){
                nums.add(k);
                k *= i;
            } k <= 1000 k 1000 {
                nums.add(k);
                k *= i;
            } nums.add(k) nums.add nums k k *= i k i int max = 1; max 1 for (int i = 0;i < nums.size();++i){
            int o = nums.get(i);
            if(o <= x&&o > max){
                max = o;
            }
        } int i = 0; int i = 0; i 0 i < nums.size() i nums.size() nums.size nums ++i ++i i {
            int o = nums.get(i);
            if(o <= x&&o > max){
                max = o;
            }
        } {
            int o = nums.get(i);
            if(o <= x&&o > max){
                max = o;
            }
        } int o = nums.get(i); o nums.get(i) nums.get nums i if(o <= x&&o > max){
                max = o;
            } o <= x&&o > max o <= x o x o > max o max {
                max = o;
            } max = o max o System.out.println(max) System.out.println System.out System System.out max String args[] args public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        ArrayList<Integer> nums = new ArrayList<Integer>();
        nums.add(1);
        for (int i = 2;i <= 31;++i){
            int k = i * i;
            while (k <= 1000){
                nums.add(k);
                k *= i;
            }
        }
        int max = 1;
        for (int i = 0;i < nums.size();++i){
            int o = nums.get(i);
            if(o <= x&&o > max){
                max = o;
            }
        }
        System.out.println(max);





    }

} public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        ArrayList<Integer> nums = new ArrayList<Integer>();
        nums.add(1);
        for (int i = 2;i <= 31;++i){
            int k = i * i;
            while (k <= 1000){
                nums.add(k);
                k *= i;
            }
        }
        int max = 1;
        for (int i = 0;i < nums.size();++i){
            int o = nums.get(i);
            if(o <= x&&o > max){
                max = o;
            }
        }
        System.out.println(max);





    }

} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        ArrayList<Integer> nums = new ArrayList<Integer>();
        nums.add(1);
        for (int i = 2;i <= 31;++i){
            int k = i * i;
            while (k <= 1000){
                nums.add(k);
                k *= i;
            }
        }
        int max = 1;
        for (int i = 0;i < nums.size();++i){
            int o = nums.get(i);
            if(o <= x&&o > max){
                max = o;
            }
        }
        System.out.println(max);





    }

}