import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();//, n = sc.nextInt();
		int sum=0,count=1,flag=0,max=-999999,min=99999;
		int[] array=new int[10000];
		//String[] array = new String[n];
		//String s=sc.next();//,t=sc.next();
		array[0]=1;
		String buff1,buff2;
		for(int i=2;i<=31;i++) {
			for(int j=2;j<=10;j++) {
				if(Math.pow(i,j)>n)break;
				array[count]=(int) Math.pow(i, j);
			}
			count++;
		}
		Arrays.sort(array);
		for(int i=9999;i>=0;i--) {
			if(array[i]<=n) {
				System.out.println(array[i]);
				break;
			}
		}
	}
	public static int sample(int n) {
		return n;
	}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();//, n = sc.nextInt();
		int sum=0,count=1,flag=0,max=-999999,min=99999;
		int[] array=new int[10000];
		//String[] array = new String[n];
		//String s=sc.next();//,t=sc.next();
		array[0]=1;
		String buff1,buff2;
		for(int i=2;i<=31;i++) {
			for(int j=2;j<=10;j++) {
				if(Math.pow(i,j)>n)break;
				array[count]=(int) Math.pow(i, j);
			}
			count++;
		}
		Arrays.sort(array);
		for(int i=9999;i>=0;i--) {
			if(array[i]<=n) {
				System.out.println(array[i]);
				break;
			}
		}
	}
	public static int sample(int n) {
		return n;
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();//, n = sc.nextInt();
		int sum=0,count=1,flag=0,max=-999999,min=99999;
		int[] array=new int[10000];
		//String[] array = new String[n];
		//String s=sc.next();//,t=sc.next();
		array[0]=1;
		String buff1,buff2;
		for(int i=2;i<=31;i++) {
			for(int j=2;j<=10;j++) {
				if(Math.pow(i,j)>n)break;
				array[count]=(int) Math.pow(i, j);
			}
			count++;
		}
		Arrays.sort(array);
		for(int i=9999;i>=0;i--) {
			if(array[i]<=n) {
				System.out.println(array[i]);
				break;
			}
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();//, n = sc.nextInt();
		int sum=0,count=1,flag=0,max=-999999,min=99999;
		int[] array=new int[10000];
		//String[] array = new String[n];
		//String s=sc.next();//,t=sc.next();
		array[0]=1;
		String buff1,buff2;
		for(int i=2;i<=31;i++) {
			for(int j=2;j<=10;j++) {
				if(Math.pow(i,j)>n)break;
				array[count]=(int) Math.pow(i, j);
			}
			count++;
		}
		Arrays.sort(array);
		for(int i=9999;i>=0;i--) {
			if(array[i]<=n) {
				System.out.println(array[i]);
				break;
			}
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int sum=0 sum 0 count=1 count 1 flag=0 flag 0 max=-999999 max -999999 999999 min=99999; min 99999 int[] array=new int[10000]; array new int[10000] 10000 array[0]=1 array[0] array 0 1 String buff1 buff1 buff2; buff2 for(int i=2;i<=31;i++) {
			for(int j=2;j<=10;j++) {
				if(Math.pow(i,j)>n)break;
				array[count]=(int) Math.pow(i, j);
			}
			count++;
		} int i=2; int i=2; i 2 i<=31 i 31 i++ i++ i {
			for(int j=2;j<=10;j++) {
				if(Math.pow(i,j)>n)break;
				array[count]=(int) Math.pow(i, j);
			}
			count++;
		} {
			for(int j=2;j<=10;j++) {
				if(Math.pow(i,j)>n)break;
				array[count]=(int) Math.pow(i, j);
			}
			count++;
		} for(int j=2;j<=10;j++) {
				if(Math.pow(i,j)>n)break;
				array[count]=(int) Math.pow(i, j);
			} int j=2; int j=2; j 2 j<=10 j 10 j++ j++ j {
				if(Math.pow(i,j)>n)break;
				array[count]=(int) Math.pow(i, j);
			} {
				if(Math.pow(i,j)>n)break;
				array[count]=(int) Math.pow(i, j);
			} if(Math.pow(i,j)>n)break; Math.pow(i,j)>n Math.pow(i,j) Math.pow Math i j n break; array[count]=(int) Math.pow(i, j) array[count] array count (int) Math.pow(i, j) Math.pow Math i j count++ count Arrays.sort(array) Arrays.sort Arrays array for(int i=9999;i>=0;i--) {
			if(array[i]<=n) {
				System.out.println(array[i]);
				break;
			}
		} int i=9999; int i=9999; i 9999 i>=0 i 0 i-- i-- i {
			if(array[i]<=n) {
				System.out.println(array[i]);
				break;
			}
		} {
			if(array[i]<=n) {
				System.out.println(array[i]);
				break;
			}
		} if(array[i]<=n) {
				System.out.println(array[i]);
				break;
			} array[i]<=n array[i] array i n {
				System.out.println(array[i]);
				break;
			} System.out.println(array[i]) System.out.println System.out System System.out array[i] array i break; String[] args args public static int sample(int n) {
		return n;
	} sample {
		return n;
	} return n; n int n n public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();//, n = sc.nextInt();
		int sum=0,count=1,flag=0,max=-999999,min=99999;
		int[] array=new int[10000];
		//String[] array = new String[n];
		//String s=sc.next();//,t=sc.next();
		array[0]=1;
		String buff1,buff2;
		for(int i=2;i<=31;i++) {
			for(int j=2;j<=10;j++) {
				if(Math.pow(i,j)>n)break;
				array[count]=(int) Math.pow(i, j);
			}
			count++;
		}
		Arrays.sort(array);
		for(int i=9999;i>=0;i--) {
			if(array[i]<=n) {
				System.out.println(array[i]);
				break;
			}
		}
	}
	public static int sample(int n) {
		return n;
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();//, n = sc.nextInt();
		int sum=0,count=1,flag=0,max=-999999,min=99999;
		int[] array=new int[10000];
		//String[] array = new String[n];
		//String s=sc.next();//,t=sc.next();
		array[0]=1;
		String buff1,buff2;
		for(int i=2;i<=31;i++) {
			for(int j=2;j<=10;j++) {
				if(Math.pow(i,j)>n)break;
				array[count]=(int) Math.pow(i, j);
			}
			count++;
		}
		Arrays.sort(array);
		for(int i=9999;i>=0;i--) {
			if(array[i]<=n) {
				System.out.println(array[i]);
				break;
			}
		}
	}
	public static int sample(int n) {
		return n;
	}

} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();//, n = sc.nextInt();
		int sum=0,count=1,flag=0,max=-999999,min=99999;
		int[] array=new int[10000];
		//String[] array = new String[n];
		//String s=sc.next();//,t=sc.next();
		array[0]=1;
		String buff1,buff2;
		for(int i=2;i<=31;i++) {
			for(int j=2;j<=10;j++) {
				if(Math.pow(i,j)>n)break;
				array[count]=(int) Math.pow(i, j);
			}
			count++;
		}
		Arrays.sort(array);
		for(int i=9999;i>=0;i--) {
			if(array[i]<=n) {
				System.out.println(array[i]);
				break;
			}
		}
	}
	public static int sample(int n) {
		return n;
	}

}
