import java.util.Scanner;

class Main{

	public static void main(String[] args) {


		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int data[] = new int[x/2];
		int i= 2;
		int count = 0;
		
		if(x == 1){
			System.out.println(x);
		}else{

			while(i < data.length){
				int z = i;
				while(z <= x){
					z *= i;

				}
				z /= i;
				data[count] = z;
				i++;
				count++;
			}
			int max = 0;
			for(int j = 0;j < data.length;j++){
				max = Math.max(max, data[j]);	
			}

			System.out.println(max);




		}
	}





}



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

	public static void main(String[] args) {


		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int data[] = new int[x/2];
		int i= 2;
		int count = 0;
		
		if(x == 1){
			System.out.println(x);
		}else{

			while(i < data.length){
				int z = i;
				while(z <= x){
					z *= i;

				}
				z /= i;
				data[count] = z;
				i++;
				count++;
			}
			int max = 0;
			for(int j = 0;j < data.length;j++){
				max = Math.max(max, data[j]);	
			}

			System.out.println(max);




		}
	}





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


		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int data[] = new int[x/2];
		int i= 2;
		int count = 0;
		
		if(x == 1){
			System.out.println(x);
		}else{

			while(i < data.length){
				int z = i;
				while(z <= x){
					z *= i;

				}
				z /= i;
				data[count] = z;
				i++;
				count++;
			}
			int max = 0;
			for(int j = 0;j < data.length;j++){
				max = Math.max(max, data[j]);	
			}

			System.out.println(max);




		}
	} main {


		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int data[] = new int[x/2];
		int i= 2;
		int count = 0;
		
		if(x == 1){
			System.out.println(x);
		}else{

			while(i < data.length){
				int z = i;
				while(z <= x){
					z *= i;

				}
				z /= i;
				data[count] = z;
				i++;
				count++;
			}
			int max = 0;
			for(int j = 0;j < data.length;j++){
				max = Math.max(max, data[j]);	
			}

			System.out.println(max);




		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan int data[] = new int[x/2]; data new int[x/2] x/2 x 2 int i= 2; i 2 int count = 0; count 0 if(x == 1){
			System.out.println(x);
		}else{

			while(i < data.length){
				int z = i;
				while(z <= x){
					z *= i;

				}
				z /= i;
				data[count] = z;
				i++;
				count++;
			}
			int max = 0;
			for(int j = 0;j < data.length;j++){
				max = Math.max(max, data[j]);	
			}

			System.out.println(max);




		} x == 1 x 1 {
			System.out.println(x);
		} System.out.println(x) System.out.println System.out System System.out x {

			while(i < data.length){
				int z = i;
				while(z <= x){
					z *= i;

				}
				z /= i;
				data[count] = z;
				i++;
				count++;
			}
			int max = 0;
			for(int j = 0;j < data.length;j++){
				max = Math.max(max, data[j]);	
			}

			System.out.println(max);




		} while(i < data.length){
				int z = i;
				while(z <= x){
					z *= i;

				}
				z /= i;
				data[count] = z;
				i++;
				count++;
			} i < data.length i data.length data data.length {
				int z = i;
				while(z <= x){
					z *= i;

				}
				z /= i;
				data[count] = z;
				i++;
				count++;
			} int z = i; z i while(z <= x){
					z *= i;

				} z <= x z x {
					z *= i;

				} z *= i z i z /= i z i data[count] = z data[count] data count z i++ i count++ count int max = 0; max 0 for(int j = 0;j < data.length;j++){
				max = Math.max(max, data[j]);	
			} int j = 0; int j = 0; j 0 j < data.length j data.length data data.length j++ j++ j {
				max = Math.max(max, data[j]);	
			} {
				max = Math.max(max, data[j]);	
			} max = Math.max(max, data[j]) max Math.max(max, data[j]) Math.max Math max data[j] data j System.out.println(max) System.out.println System.out System System.out max String[] args args
import java.util.Scanner;

class Main{

	public static void main(String[] args) {


		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int data[] = new int[x/2];
		int i= 2;
		int count = 0;
		
		if(x == 1){
			System.out.println(x);
		}else{

			while(i < data.length){
				int z = i;
				while(z <= x){
					z *= i;

				}
				z /= i;
				data[count] = z;
				i++;
				count++;
			}
			int max = 0;
			for(int j = 0;j < data.length;j++){
				max = Math.max(max, data[j]);	
			}

			System.out.println(max);




		}
	}





}




