import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = (int)Math.pow(n,0.5)+1;
        int ans = 1;
        for(int i = 2; i < max; i++){
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ans = Math.max(ans,(int)Math.pow(i,pow));
                pow++;
            }
        }
        System.out.println(ans);
    }
}
 import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = (int)Math.pow(n,0.5)+1;
        int ans = 1;
        for(int i = 2; i < max; i++){
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ans = Math.max(ans,(int)Math.pow(i,pow));
                pow++;
            }
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = (int)Math.pow(n,0.5)+1;
        int ans = 1;
        for(int i = 2; i < max; i++){
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ans = Math.max(ans,(int)Math.pow(i,pow));
                pow++;
            }
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = (int)Math.pow(n,0.5)+1;
        int ans = 1;
        for(int i = 2; i < max; i++){
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ans = Math.max(ans,(int)Math.pow(i,pow));
                pow++;
            }
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int max = (int)Math.pow(n,0.5)+1; max (int)Math.pow(n,0.5)+1 (int)Math.pow(n,0.5) Math.pow Math n 0.5 1 int ans = 1; ans 1 for(int i = 2; i < max; i++){
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ans = Math.max(ans,(int)Math.pow(i,pow));
                pow++;
            }
        } int i = 2; int i = 2; i 2 i < max i max i++ i++ i {
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ans = Math.max(ans,(int)Math.pow(i,pow));
                pow++;
            }
        } {
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ans = Math.max(ans,(int)Math.pow(i,pow));
                pow++;
            }
        } int pow = 2; pow 2 while(Math.pow(i,pow) <= n){
                ans = Math.max(ans,(int)Math.pow(i,pow));
                pow++;
            } Math.pow(i,pow) <= n Math.pow(i,pow) Math.pow Math i pow n {
                ans = Math.max(ans,(int)Math.pow(i,pow));
                pow++;
            } ans = Math.max(ans,(int)Math.pow(i,pow)) ans Math.max(ans,(int)Math.pow(i,pow)) Math.max Math ans (int)Math.pow(i,pow) Math.pow Math i pow pow++ pow System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = (int)Math.pow(n,0.5)+1;
        int ans = 1;
        for(int i = 2; i < max; i++){
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ans = Math.max(ans,(int)Math.pow(i,pow));
                pow++;
            }
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = (int)Math.pow(n,0.5)+1;
        int ans = 1;
        for(int i = 2; i < max; i++){
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ans = Math.max(ans,(int)Math.pow(i,pow));
                pow++;
            }
        }
        System.out.println(ans);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int max = (int)Math.pow(n,0.5)+1;
        int ans = 1;
        for(int i = 2; i < max; i++){
            int pow = 2;
            while(Math.pow(i,pow) <= n){
                ans = Math.max(ans,(int)Math.pow(i,pow));
                pow++;
            }
        }
        System.out.println(ans);
    }
}

