import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		
		int max=1;
		for(int t=2;t<=(int)Math.sqrt(X);t++){
			int s=1;
			while((int)Math.pow(t,s) <= X){
				s++;
			}
			if(max < (int)Math.pow(t,s-1)) max = (int)Math.pow(t,s-1);
		}

		System.out.println(max);
		
	}
} import java.util.*; util.* java class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		
		int max=1;
		for(int t=2;t<=(int)Math.sqrt(X);t++){
			int s=1;
			while((int)Math.pow(t,s) <= X){
				s++;
			}
			if(max < (int)Math.pow(t,s-1)) max = (int)Math.pow(t,s-1);
		}

		System.out.println(max);
		
	}
} Main public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		
		int max=1;
		for(int t=2;t<=(int)Math.sqrt(X);t++){
			int s=1;
			while((int)Math.pow(t,s) <= X){
				s++;
			}
			if(max < (int)Math.pow(t,s-1)) max = (int)Math.pow(t,s-1);
		}

		System.out.println(max);
		
	} main {

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		
		int max=1;
		for(int t=2;t<=(int)Math.sqrt(X);t++){
			int s=1;
			while((int)Math.pow(t,s) <= X){
				s++;
			}
			if(max < (int)Math.pow(t,s-1)) max = (int)Math.pow(t,s-1);
		}

		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 int max=1; max 1 for(int t=2;t<=(int)Math.sqrt(X);t++){
			int s=1;
			while((int)Math.pow(t,s) <= X){
				s++;
			}
			if(max < (int)Math.pow(t,s-1)) max = (int)Math.pow(t,s-1);
		} int t=2; int t=2; t 2 t<=(int)Math.sqrt(X) t (int)Math.sqrt(X) Math.sqrt Math X t++ t++ t {
			int s=1;
			while((int)Math.pow(t,s) <= X){
				s++;
			}
			if(max < (int)Math.pow(t,s-1)) max = (int)Math.pow(t,s-1);
		} {
			int s=1;
			while((int)Math.pow(t,s) <= X){
				s++;
			}
			if(max < (int)Math.pow(t,s-1)) max = (int)Math.pow(t,s-1);
		} int s=1; s 1 while((int)Math.pow(t,s) <= X){
				s++;
			} (int)Math.pow(t,s) <= X (int)Math.pow(t,s) Math.pow Math t s X {
				s++;
			} s++ s if(max < (int)Math.pow(t,s-1)) max = (int)Math.pow(t,s-1); max < (int)Math.pow(t,s-1) max (int)Math.pow(t,s-1) Math.pow Math t s-1 s 1 max = (int)Math.pow(t,s-1) max (int)Math.pow(t,s-1) Math.pow Math t s-1 s 1 System.out.println(max) System.out.println System.out System System.out max String args[] args
import java.util.*;

class Main{
	
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		
		int max=1;
		for(int t=2;t<=(int)Math.sqrt(X);t++){
			int s=1;
			while((int)Math.pow(t,s) <= X){
				s++;
			}
			if(max < (int)Math.pow(t,s-1)) max = (int)Math.pow(t,s-1);
		}

		System.out.println(max);
		
	}
}