import java.util.*;

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

		int max = 1;
		int x = scan.nextInt();

		for(int i = 1; i <= x; i++){
			int abs = 0;
			for(int j = 2; j <= x; j++){

				abs =(int) Math.pow((double)i, (double)j);

				if(abs > x){
					break;
				}
				if(abs > max){
					max = abs;
				}
			}
		}
		System.out.println(max);
	}
}	 import java.util.*; util.* java class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		int max = 1;
		int x = scan.nextInt();

		for(int i = 1; i <= x; i++){
			int abs = 0;
			for(int j = 2; j <= x; j++){

				abs =(int) Math.pow((double)i, (double)j);

				if(abs > x){
					break;
				}
				if(abs > max){
					max = abs;
				}
			}
		}
		System.out.println(max);
	}
} Main public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		int max = 1;
		int x = scan.nextInt();

		for(int i = 1; i <= x; i++){
			int abs = 0;
			for(int j = 2; j <= x; j++){

				abs =(int) Math.pow((double)i, (double)j);

				if(abs > x){
					break;
				}
				if(abs > max){
					max = abs;
				}
			}
		}
		System.out.println(max);
	} main {
		Scanner scan = new Scanner(System.in);

		int max = 1;
		int x = scan.nextInt();

		for(int i = 1; i <= x; i++){
			int abs = 0;
			for(int j = 2; j <= x; j++){

				abs =(int) Math.pow((double)i, (double)j);

				if(abs > x){
					break;
				}
				if(abs > max){
					max = abs;
				}
			}
		}
		System.out.println(max);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int max = 1; max 1 int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan for(int i = 1; i <= x; i++){
			int abs = 0;
			for(int j = 2; j <= x; j++){

				abs =(int) Math.pow((double)i, (double)j);

				if(abs > x){
					break;
				}
				if(abs > max){
					max = abs;
				}
			}
		} int i = 1; int i = 1; i 1 i <= x i x i++ i++ i {
			int abs = 0;
			for(int j = 2; j <= x; j++){

				abs =(int) Math.pow((double)i, (double)j);

				if(abs > x){
					break;
				}
				if(abs > max){
					max = abs;
				}
			}
		} {
			int abs = 0;
			for(int j = 2; j <= x; j++){

				abs =(int) Math.pow((double)i, (double)j);

				if(abs > x){
					break;
				}
				if(abs > max){
					max = abs;
				}
			}
		} int abs = 0; abs 0 for(int j = 2; j <= x; j++){

				abs =(int) Math.pow((double)i, (double)j);

				if(abs > x){
					break;
				}
				if(abs > max){
					max = abs;
				}
			} int j = 2; int j = 2; j 2 j <= x j x j++ j++ j {

				abs =(int) Math.pow((double)i, (double)j);

				if(abs > x){
					break;
				}
				if(abs > max){
					max = abs;
				}
			} {

				abs =(int) Math.pow((double)i, (double)j);

				if(abs > x){
					break;
				}
				if(abs > max){
					max = abs;
				}
			} abs =(int) Math.pow((double)i, (double)j) abs (int) Math.pow((double)i, (double)j) Math.pow Math (double)i (double)j if(abs > x){
					break;
				} abs > x abs x {
					break;
				} break; if(abs > max){
					max = abs;
				} abs > max abs max {
					max = abs;
				} max = abs max abs 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 scan = new Scanner(System.in);

		int max = 1;
		int x = scan.nextInt();

		for(int i = 1; i <= x; i++){
			int abs = 0;
			for(int j = 2; j <= x; j++){

				abs =(int) Math.pow((double)i, (double)j);

				if(abs > x){
					break;
				}
				if(abs > max){
					max = abs;
				}
			}
		}
		System.out.println(max);
	}
}	