import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int max = 0;

		if(X!=1){
			for(int b=2; b<Math.sqrt(X); b++){
				int p=2;
				int pow = (int) Math.pow(b,p);
				while(pow<=X){
					if(max<pow){
						max=pow;
					}
					p++;
					pow = (int) Math.pow(b,p);
				}
			}
		}else{
			System.out.println("1");
			return;
		}
		System.out.println(max);
    }
} import java.util.*; util.* java public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int max = 0;

		if(X!=1){
			for(int b=2; b<Math.sqrt(X); b++){
				int p=2;
				int pow = (int) Math.pow(b,p);
				while(pow<=X){
					if(max<pow){
						max=pow;
					}
					p++;
					pow = (int) Math.pow(b,p);
				}
			}
		}else{
			System.out.println("1");
			return;
		}
		System.out.println(max);
    }
} Main public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int max = 0;

		if(X!=1){
			for(int b=2; b<Math.sqrt(X); b++){
				int p=2;
				int pow = (int) Math.pow(b,p);
				while(pow<=X){
					if(max<pow){
						max=pow;
					}
					p++;
					pow = (int) Math.pow(b,p);
				}
			}
		}else{
			System.out.println("1");
			return;
		}
		System.out.println(max);
    } main {
    	Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int max = 0;

		if(X!=1){
			for(int b=2; b<Math.sqrt(X); b++){
				int p=2;
				int pow = (int) Math.pow(b,p);
				while(pow<=X){
					if(max<pow){
						max=pow;
					}
					p++;
					pow = (int) Math.pow(b,p);
				}
			}
		}else{
			System.out.println("1");
			return;
		}
		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 if(X!=1){
			for(int b=2; b<Math.sqrt(X); b++){
				int p=2;
				int pow = (int) Math.pow(b,p);
				while(pow<=X){
					if(max<pow){
						max=pow;
					}
					p++;
					pow = (int) Math.pow(b,p);
				}
			}
		}else{
			System.out.println("1");
			return;
		} X!=1 X 1 {
			for(int b=2; b<Math.sqrt(X); b++){
				int p=2;
				int pow = (int) Math.pow(b,p);
				while(pow<=X){
					if(max<pow){
						max=pow;
					}
					p++;
					pow = (int) Math.pow(b,p);
				}
			}
		} for(int b=2; b<Math.sqrt(X); b++){
				int p=2;
				int pow = (int) Math.pow(b,p);
				while(pow<=X){
					if(max<pow){
						max=pow;
					}
					p++;
					pow = (int) Math.pow(b,p);
				}
			} int b=2; int b=2; b 2 b<Math.sqrt(X) b Math.sqrt(X) Math.sqrt Math X b++ b++ b {
				int p=2;
				int pow = (int) Math.pow(b,p);
				while(pow<=X){
					if(max<pow){
						max=pow;
					}
					p++;
					pow = (int) Math.pow(b,p);
				}
			} {
				int p=2;
				int pow = (int) Math.pow(b,p);
				while(pow<=X){
					if(max<pow){
						max=pow;
					}
					p++;
					pow = (int) Math.pow(b,p);
				}
			} int p=2; p 2 int pow = (int) Math.pow(b,p); pow (int) Math.pow(b,p) Math.pow Math b p while(pow<=X){
					if(max<pow){
						max=pow;
					}
					p++;
					pow = (int) Math.pow(b,p);
				} pow<=X pow X {
					if(max<pow){
						max=pow;
					}
					p++;
					pow = (int) Math.pow(b,p);
				} if(max<pow){
						max=pow;
					} max<pow max pow {
						max=pow;
					} max=pow max pow p++ p pow = (int) Math.pow(b,p) pow (int) Math.pow(b,p) Math.pow Math b p {
			System.out.println("1");
			return;
		} System.out.println("1") System.out.println System.out System System.out "1" return; 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){
    	Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int max = 0;

		if(X!=1){
			for(int b=2; b<Math.sqrt(X); b++){
				int p=2;
				int pow = (int) Math.pow(b,p);
				while(pow<=X){
					if(max<pow){
						max=pow;
					}
					p++;
					pow = (int) Math.pow(b,p);
				}
			}
		}else{
			System.out.println("1");
			return;
		}
		System.out.println(max);
    }
} public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int max = 0;

		if(X!=1){
			for(int b=2; b<Math.sqrt(X); b++){
				int p=2;
				int pow = (int) Math.pow(b,p);
				while(pow<=X){
					if(max<pow){
						max=pow;
					}
					p++;
					pow = (int) Math.pow(b,p);
				}
			}
		}else{
			System.out.println("1");
			return;
		}
		System.out.println(max);
    }
} Main
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int max = 0;

		if(X!=1){
			for(int b=2; b<Math.sqrt(X); b++){
				int p=2;
				int pow = (int) Math.pow(b,p);
				while(pow<=X){
					if(max<pow){
						max=pow;
					}
					p++;
					pow = (int) Math.pow(b,p);
				}
			}
		}else{
			System.out.println("1");
			return;
		}
		System.out.println(max);
    }
}