import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double max = 1;

        for(int i=1; i<=n; i++){
            double pow = 0;
            for(int j=2; j<=n; j++){
                pow = Math.pow(i, j);
                if(pow > n){
                    break;
                }
                if(pow >= max){
                    max = pow;
                }
            }
        }

        System.out.println((int)max);
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }

    public static int gcd(int a, int b){
        if (b == 0) return a;
        return gcd(b, a % b);
    }

    public static int lcm(int a, int b){
        return a * b / gcd(a, b);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double max = 1;

        for(int i=1; i<=n; i++){
            double pow = 0;
            for(int j=2; j<=n; j++){
                pow = Math.pow(i, j);
                if(pow > n){
                    break;
                }
                if(pow >= max){
                    max = pow;
                }
            }
        }

        System.out.println((int)max);
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }

    public static int gcd(int a, int b){
        if (b == 0) return a;
        return gcd(b, a % b);
    }

    public static int lcm(int a, int b){
        return a * b / gcd(a, b);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double max = 1;

        for(int i=1; i<=n; i++){
            double pow = 0;
            for(int j=2; j<=n; j++){
                pow = Math.pow(i, j);
                if(pow > n){
                    break;
                }
                if(pow >= max){
                    max = pow;
                }
            }
        }

        System.out.println((int)max);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double max = 1;

        for(int i=1; i<=n; i++){
            double pow = 0;
            for(int j=2; j<=n; j++){
                pow = Math.pow(i, j);
                if(pow > n){
                    break;
                }
                if(pow >= max){
                    max = pow;
                }
            }
        }

        System.out.println((int)max);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc double max = 1; max 1 for(int i=1; i<=n; i++){
            double pow = 0;
            for(int j=2; j<=n; j++){
                pow = Math.pow(i, j);
                if(pow > n){
                    break;
                }
                if(pow >= max){
                    max = pow;
                }
            }
        } int i=1; int i=1; i 1 i<=n i n i++ i++ i {
            double pow = 0;
            for(int j=2; j<=n; j++){
                pow = Math.pow(i, j);
                if(pow > n){
                    break;
                }
                if(pow >= max){
                    max = pow;
                }
            }
        } {
            double pow = 0;
            for(int j=2; j<=n; j++){
                pow = Math.pow(i, j);
                if(pow > n){
                    break;
                }
                if(pow >= max){
                    max = pow;
                }
            }
        } double pow = 0; pow 0 for(int j=2; j<=n; j++){
                pow = Math.pow(i, j);
                if(pow > n){
                    break;
                }
                if(pow >= max){
                    max = pow;
                }
            } int j=2; int j=2; j 2 j<=n j n j++ j++ j {
                pow = Math.pow(i, j);
                if(pow > n){
                    break;
                }
                if(pow >= max){
                    max = pow;
                }
            } {
                pow = Math.pow(i, j);
                if(pow > n){
                    break;
                }
                if(pow >= max){
                    max = pow;
                }
            } pow = Math.pow(i, j) pow Math.pow(i, j) Math.pow Math i j if(pow > n){
                    break;
                } pow > n pow n {
                    break;
                } break; if(pow >= max){
                    max = pow;
                } pow >= max pow max {
                    max = pow;
                } max = pow max pow System.out.println((int)max) System.out.println System.out System System.out (int)max String[] args args public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    } printArray {
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    } for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        } int i=0; int i=0; i 0 i<array.length i array.length array array.length i++ i++ i {
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        } {
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        } if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            } i == array.length i array.length array array.length {
                System.out.println(array[i]);
            } System.out.println(array[i]) System.out.println System.out System System.out array[i] array i {
                System.out.print(String.format("%d ", array[i]));
            } System.out.print(String.format("%d ", array[i])) System.out.print System.out System System.out String.format("%d ", array[i]) String.format String "%d " array[i] array i int[] array array public static int gcd(int a, int b){
        if (b == 0) return a;
        return gcd(b, a % b);
    } gcd {
        if (b == 0) return a;
        return gcd(b, a % b);
    } if (b == 0) return a; b == 0 b 0 return a; a return gcd(b, a % b); gcd(b, a % b) gcd b a % b a b int a a int b b public static int lcm(int a, int b){
        return a * b / gcd(a, b);
    } lcm {
        return a * b / gcd(a, b);
    } return a * b / gcd(a, b); a * b / gcd(a, b) a * b a b gcd(a, b) gcd a b int a a int b b public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double max = 1;

        for(int i=1; i<=n; i++){
            double pow = 0;
            for(int j=2; j<=n; j++){
                pow = Math.pow(i, j);
                if(pow > n){
                    break;
                }
                if(pow >= max){
                    max = pow;
                }
            }
        }

        System.out.println((int)max);
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }

    public static int gcd(int a, int b){
        if (b == 0) return a;
        return gcd(b, a % b);
    }

    public static int lcm(int a, int b){
        return a * b / gcd(a, b);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double max = 1;

        for(int i=1; i<=n; i++){
            double pow = 0;
            for(int j=2; j<=n; j++){
                pow = Math.pow(i, j);
                if(pow > n){
                    break;
                }
                if(pow >= max){
                    max = pow;
                }
            }
        }

        System.out.println((int)max);
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }

    public static int gcd(int a, int b){
        if (b == 0) return a;
        return gcd(b, a % b);
    }

    public static int lcm(int a, int b){
        return a * b / gcd(a, b);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double max = 1;

        for(int i=1; i<=n; i++){
            double pow = 0;
            for(int j=2; j<=n; j++){
                pow = Math.pow(i, j);
                if(pow > n){
                    break;
                }
                if(pow >= max){
                    max = pow;
                }
            }
        }

        System.out.println((int)max);
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }

    public static int gcd(int a, int b){
        if (b == 0) return a;
        return gcd(b, a % b);
    }

    public static int lcm(int a, int b){
        return a * b / gcd(a, b);
    }
}
