import java.util.*;

public class Main {


    public static void main(String[] args) {
    	Scanner sc=new Scanner(System.in);

    	int X=sc.nextInt();
    	
    	boolean[] expX=new boolean[X+1];
    	
    	Arrays.fill(expX,false);
      
      	expX[1]=true;
    	
    	for(int b=2;b<=X;b++) {
    		
    		int v=b*b;
    		
    		while(v<=X) {
    			
    			expX[v]=true;
    			
    			v*=b;
    			
    		}
    	}
    	
    	for(int i=X;i>=0;i--) {
    		
    		if(expX[i]) {
    			System.out.println(i);
    			return ;
    		}
    		
    	}

    }


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


    public static void main(String[] args) {
    	Scanner sc=new Scanner(System.in);

    	int X=sc.nextInt();
    	
    	boolean[] expX=new boolean[X+1];
    	
    	Arrays.fill(expX,false);
      
      	expX[1]=true;
    	
    	for(int b=2;b<=X;b++) {
    		
    		int v=b*b;
    		
    		while(v<=X) {
    			
    			expX[v]=true;
    			
    			v*=b;
    			
    		}
    	}
    	
    	for(int i=X;i>=0;i--) {
    		
    		if(expX[i]) {
    			System.out.println(i);
    			return ;
    		}
    		
    	}

    }


} Main public static void main(String[] args) {
    	Scanner sc=new Scanner(System.in);

    	int X=sc.nextInt();
    	
    	boolean[] expX=new boolean[X+1];
    	
    	Arrays.fill(expX,false);
      
      	expX[1]=true;
    	
    	for(int b=2;b<=X;b++) {
    		
    		int v=b*b;
    		
    		while(v<=X) {
    			
    			expX[v]=true;
    			
    			v*=b;
    			
    		}
    	}
    	
    	for(int i=X;i>=0;i--) {
    		
    		if(expX[i]) {
    			System.out.println(i);
    			return ;
    		}
    		
    	}

    } main {
    	Scanner sc=new Scanner(System.in);

    	int X=sc.nextInt();
    	
    	boolean[] expX=new boolean[X+1];
    	
    	Arrays.fill(expX,false);
      
      	expX[1]=true;
    	
    	for(int b=2;b<=X;b++) {
    		
    		int v=b*b;
    		
    		while(v<=X) {
    			
    			expX[v]=true;
    			
    			v*=b;
    			
    		}
    	}
    	
    	for(int i=X;i>=0;i--) {
    		
    		if(expX[i]) {
    			System.out.println(i);
    			return ;
    		}
    		
    	}

    } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int X=sc.nextInt(); X sc.nextInt() sc.nextInt sc boolean[] expX=new boolean[X+1]; expX new boolean[X+1] X+1 X 1 Arrays.fill(expX,false) Arrays.fill Arrays expX false expX[1]=true expX[1] expX 1 true for(int b=2;b<=X;b++) {
    		
    		int v=b*b;
    		
    		while(v<=X) {
    			
    			expX[v]=true;
    			
    			v*=b;
    			
    		}
    	} int b=2; int b=2; b 2 b<=X b X b++ b++ b {
    		
    		int v=b*b;
    		
    		while(v<=X) {
    			
    			expX[v]=true;
    			
    			v*=b;
    			
    		}
    	} {
    		
    		int v=b*b;
    		
    		while(v<=X) {
    			
    			expX[v]=true;
    			
    			v*=b;
    			
    		}
    	} int v=b*b; v b*b b b while(v<=X) {
    			
    			expX[v]=true;
    			
    			v*=b;
    			
    		} v<=X v X {
    			
    			expX[v]=true;
    			
    			v*=b;
    			
    		} expX[v]=true expX[v] expX v true v*=b v b for(int i=X;i>=0;i--) {
    		
    		if(expX[i]) {
    			System.out.println(i);
    			return ;
    		}
    		
    	} int i=X; int i=X; i X i>=0 i 0 i-- i-- i {
    		
    		if(expX[i]) {
    			System.out.println(i);
    			return ;
    		}
    		
    	} {
    		
    		if(expX[i]) {
    			System.out.println(i);
    			return ;
    		}
    		
    	} if(expX[i]) {
    			System.out.println(i);
    			return ;
    		} expX[i] expX i {
    			System.out.println(i);
    			return ;
    		} System.out.println(i) System.out.println System.out System System.out i return ; String[] args args public class Main {


    public static void main(String[] args) {
    	Scanner sc=new Scanner(System.in);

    	int X=sc.nextInt();
    	
    	boolean[] expX=new boolean[X+1];
    	
    	Arrays.fill(expX,false);
      
      	expX[1]=true;
    	
    	for(int b=2;b<=X;b++) {
    		
    		int v=b*b;
    		
    		while(v<=X) {
    			
    			expX[v]=true;
    			
    			v*=b;
    			
    		}
    	}
    	
    	for(int i=X;i>=0;i--) {
    		
    		if(expX[i]) {
    			System.out.println(i);
    			return ;
    		}
    		
    	}

    }


} public class Main {


    public static void main(String[] args) {
    	Scanner sc=new Scanner(System.in);

    	int X=sc.nextInt();
    	
    	boolean[] expX=new boolean[X+1];
    	
    	Arrays.fill(expX,false);
      
      	expX[1]=true;
    	
    	for(int b=2;b<=X;b++) {
    		
    		int v=b*b;
    		
    		while(v<=X) {
    			
    			expX[v]=true;
    			
    			v*=b;
    			
    		}
    	}
    	
    	for(int i=X;i>=0;i--) {
    		
    		if(expX[i]) {
    			System.out.println(i);
    			return ;
    		}
    		
    	}

    }


} Main
import java.util.*;

public class Main {


    public static void main(String[] args) {
    	Scanner sc=new Scanner(System.in);

    	int X=sc.nextInt();
    	
    	boolean[] expX=new boolean[X+1];
    	
    	Arrays.fill(expX,false);
      
      	expX[1]=true;
    	
    	for(int b=2;b<=X;b++) {
    		
    		int v=b*b;
    		
    		while(v<=X) {
    			
    			expX[v]=true;
    			
    			v*=b;
    			
    		}
    	}
    	
    	for(int i=X;i>=0;i--) {
    		
    		if(expX[i]) {
    			System.out.println(i);
    			return ;
    		}
    		
    	}

    }


}