import java.util.*;
public class Main{
	public static void main(String[] args){
		//1<=x<=1000
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();//Xが与えられる！
		int max = 0;//現在の最大のべき乗
		for(int b = 1;b <= x;b++){//
			for(int q = 2;q <= 1000;q++){
				if(Math.pow(b, q) <= x){
					max = (Math.max((int)Math.pow(b, q), max));
				}
			}
		}
		System.out.println(max);
		
		
		
	
	}
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
		//1<=x<=1000
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();//Xが与えられる！
		int max = 0;//現在の最大のべき乗
		for(int b = 1;b <= x;b++){//
			for(int q = 2;q <= 1000;q++){
				if(Math.pow(b, q) <= x){
					max = (Math.max((int)Math.pow(b, q), max));
				}
			}
		}
		System.out.println(max);
		
		
		
	
	}
} Main public static void main(String[] args){
		//1<=x<=1000
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();//Xが与えられる！
		int max = 0;//現在の最大のべき乗
		for(int b = 1;b <= x;b++){//
			for(int q = 2;q <= 1000;q++){
				if(Math.pow(b, q) <= x){
					max = (Math.max((int)Math.pow(b, q), max));
				}
			}
		}
		System.out.println(max);
		
		
		
	
	} main {
		//1<=x<=1000
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();//Xが与えられる！
		int max = 0;//現在の最大のべき乗
		for(int b = 1;b <= x;b++){//
			for(int q = 2;q <= 1000;q++){
				if(Math.pow(b, q) <= x){
					max = (Math.max((int)Math.pow(b, q), max));
				}
			}
		}
		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 = 0; max 0 for(int b = 1;b <= x;b++){//
			for(int q = 2;q <= 1000;q++){
				if(Math.pow(b, q) <= x){
					max = (Math.max((int)Math.pow(b, q), max));
				}
			}
		} int b = 1; int b = 1; b 1 b <= x b x b++ b++ b {//
			for(int q = 2;q <= 1000;q++){
				if(Math.pow(b, q) <= x){
					max = (Math.max((int)Math.pow(b, q), max));
				}
			}
		} {//
			for(int q = 2;q <= 1000;q++){
				if(Math.pow(b, q) <= x){
					max = (Math.max((int)Math.pow(b, q), max));
				}
			}
		} for(int q = 2;q <= 1000;q++){
				if(Math.pow(b, q) <= x){
					max = (Math.max((int)Math.pow(b, q), max));
				}
			} int q = 2; int q = 2; q 2 q <= 1000 q 1000 q++ q++ q {
				if(Math.pow(b, q) <= x){
					max = (Math.max((int)Math.pow(b, q), max));
				}
			} {
				if(Math.pow(b, q) <= x){
					max = (Math.max((int)Math.pow(b, q), max));
				}
			} if(Math.pow(b, q) <= x){
					max = (Math.max((int)Math.pow(b, q), max));
				} Math.pow(b, q) <= x Math.pow(b, q) Math.pow Math b q x {
					max = (Math.max((int)Math.pow(b, q), max));
				} max = (Math.max((int)Math.pow(b, q), max)) max (Math.max((int)Math.pow(b, q), max)) Math.max Math (int)Math.pow(b, q) Math.pow Math b q max System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main{
	public static void main(String[] args){
		//1<=x<=1000
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();//Xが与えられる！
		int max = 0;//現在の最大のべき乗
		for(int b = 1;b <= x;b++){//
			for(int q = 2;q <= 1000;q++){
				if(Math.pow(b, q) <= x){
					max = (Math.max((int)Math.pow(b, q), max));
				}
			}
		}
		System.out.println(max);
		
		
		
	
	}
} public class Main{
	public static void main(String[] args){
		//1<=x<=1000
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();//Xが与えられる！
		int max = 0;//現在の最大のべき乗
		for(int b = 1;b <= x;b++){//
			for(int q = 2;q <= 1000;q++){
				if(Math.pow(b, q) <= x){
					max = (Math.max((int)Math.pow(b, q), max));
				}
			}
		}
		System.out.println(max);
		
		
		
	
	}
} Main
import java.util.*;
public class Main{
	public static void main(String[] args){
		//1<=x<=1000
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();//Xが与えられる！
		int max = 0;//現在の最大のべき乗
		for(int b = 1;b <= x;b++){//
			for(int q = 2;q <= 1000;q++){
				if(Math.pow(b, q) <= x){
					max = (Math.max((int)Math.pow(b, q), max));
				}
			}
		}
		System.out.println(max);
		
		
		
	
	}
}
