import java.util.Scanner;

public class Main {


    private static int pow(int base,int os) {
        if(os == 0)
            return 1;
        int temp = pow(base, os/2);
        if (os % 2 == 0)
            return temp * temp;
        else
            return (base * temp * temp);
    }

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        int ans = 0;
        for(int i=1;i<=x;++i) {
            for (int j = 2; j <= x; ++j) {
                int num = pow(i, j);
                if (num > x)
                    break;
                ans = Math.max(ans, pow(i, j));
            }
        }
        System.out.println(x==1?1:ans);

    }
} import java.util.Scanner; Scanner java.util public class Main {


    private static int pow(int base,int os) {
        if(os == 0)
            return 1;
        int temp = pow(base, os/2);
        if (os % 2 == 0)
            return temp * temp;
        else
            return (base * temp * temp);
    }

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        int ans = 0;
        for(int i=1;i<=x;++i) {
            for (int j = 2; j <= x; ++j) {
                int num = pow(i, j);
                if (num > x)
                    break;
                ans = Math.max(ans, pow(i, j));
            }
        }
        System.out.println(x==1?1:ans);

    }
} Main private static int pow(int base,int os) {
        if(os == 0)
            return 1;
        int temp = pow(base, os/2);
        if (os % 2 == 0)
            return temp * temp;
        else
            return (base * temp * temp);
    } pow {
        if(os == 0)
            return 1;
        int temp = pow(base, os/2);
        if (os % 2 == 0)
            return temp * temp;
        else
            return (base * temp * temp);
    } if(os == 0)
            return 1; os == 0 os 0 return 1; 1 int temp = pow(base, os/2); temp pow(base, os/2) pow base os/2 os 2 if (os % 2 == 0)
            return temp * temp;
        else
            return (base * temp * temp); os % 2 == 0 os % 2 os 2 0 return temp * temp; temp * temp temp temp return (base * temp * temp); (base * temp * temp) base * temp * temp base temp temp int base base int os os public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        int ans = 0;
        for(int i=1;i<=x;++i) {
            for (int j = 2; j <= x; ++j) {
                int num = pow(i, j);
                if (num > x)
                    break;
                ans = Math.max(ans, pow(i, j));
            }
        }
        System.out.println(x==1?1:ans);

    } main {

        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        int ans = 0;
        for(int i=1;i<=x;++i) {
            for (int j = 2; j <= x; ++j) {
                int num = pow(i, j);
                if (num > x)
                    break;
                ans = Math.max(ans, pow(i, j));
            }
        }
        System.out.println(x==1?1:ans);

    } Scanner input = new Scanner(System.in); input new Scanner(System.in) int x = input.nextInt(); x input.nextInt() input.nextInt input int ans = 0; ans 0 for(int i=1;i<=x;++i) {
            for (int j = 2; j <= x; ++j) {
                int num = pow(i, j);
                if (num > x)
                    break;
                ans = Math.max(ans, pow(i, j));
            }
        } int i=1; int i=1; i 1 i<=x i x ++i ++i i {
            for (int j = 2; j <= x; ++j) {
                int num = pow(i, j);
                if (num > x)
                    break;
                ans = Math.max(ans, pow(i, j));
            }
        } {
            for (int j = 2; j <= x; ++j) {
                int num = pow(i, j);
                if (num > x)
                    break;
                ans = Math.max(ans, pow(i, j));
            }
        } for (int j = 2; j <= x; ++j) {
                int num = pow(i, j);
                if (num > x)
                    break;
                ans = Math.max(ans, pow(i, j));
            } int j = 2; int j = 2; j 2 j <= x j x ++j ++j j {
                int num = pow(i, j);
                if (num > x)
                    break;
                ans = Math.max(ans, pow(i, j));
            } {
                int num = pow(i, j);
                if (num > x)
                    break;
                ans = Math.max(ans, pow(i, j));
            } int num = pow(i, j); num pow(i, j) pow i j if (num > x)
                    break; num > x num x break; ans = Math.max(ans, pow(i, j)) ans Math.max(ans, pow(i, j)) Math.max Math ans pow(i, j) pow i j System.out.println(x==1?1:ans) System.out.println System.out System System.out x==1?1:ans x==1 x 1 1 ans String[] args args public class Main {


    private static int pow(int base,int os) {
        if(os == 0)
            return 1;
        int temp = pow(base, os/2);
        if (os % 2 == 0)
            return temp * temp;
        else
            return (base * temp * temp);
    }

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        int ans = 0;
        for(int i=1;i<=x;++i) {
            for (int j = 2; j <= x; ++j) {
                int num = pow(i, j);
                if (num > x)
                    break;
                ans = Math.max(ans, pow(i, j));
            }
        }
        System.out.println(x==1?1:ans);

    }
} public class Main {


    private static int pow(int base,int os) {
        if(os == 0)
            return 1;
        int temp = pow(base, os/2);
        if (os % 2 == 0)
            return temp * temp;
        else
            return (base * temp * temp);
    }

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        int ans = 0;
        for(int i=1;i<=x;++i) {
            for (int j = 2; j <= x; ++j) {
                int num = pow(i, j);
                if (num > x)
                    break;
                ans = Math.max(ans, pow(i, j));
            }
        }
        System.out.println(x==1?1:ans);

    }
} Main
import java.util.Scanner;

public class Main {


    private static int pow(int base,int os) {
        if(os == 0)
            return 1;
        int temp = pow(base, os/2);
        if (os % 2 == 0)
            return temp * temp;
        else
            return (base * temp * temp);
    }

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        int ans = 0;
        for(int i=1;i<=x;++i) {
            for (int j = 2; j <= x; ++j) {
                int num = pow(i, j);
                if (num > x)
                    break;
                ans = Math.max(ans, pow(i, j));
            }
        }
        System.out.println(x==1?1:ans);

    }
}
