import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int X = Integer.parseInt(br.readLine());
		long ans = 0;
		for(int x=1; x<32; x++) {
			for(int b=2; b<=10; b++) {
				int B = (int)Math.pow(x, b);
				if(B<=X) {
					if(B>ans) {
						ans=B;
					}
				}else{
					break;
				}
			}
		}
		
		System.out.println(ans);	
	}
} import java.util.*; util.* java import java.io.*; io.* java public class Main {

	public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int X = Integer.parseInt(br.readLine());
		long ans = 0;
		for(int x=1; x<32; x++) {
			for(int b=2; b<=10; b++) {
				int B = (int)Math.pow(x, b);
				if(B<=X) {
					if(B>ans) {
						ans=B;
					}
				}else{
					break;
				}
			}
		}
		
		System.out.println(ans);	
	}
} Main public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int X = Integer.parseInt(br.readLine());
		long ans = 0;
		for(int x=1; x<32; x++) {
			for(int b=2; b<=10; b++) {
				int B = (int)Math.pow(x, b);
				if(B<=X) {
					if(B>ans) {
						ans=B;
					}
				}else{
					break;
				}
			}
		}
		
		System.out.println(ans);	
	} main {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int X = Integer.parseInt(br.readLine());
		long ans = 0;
		for(int x=1; x<32; x++) {
			for(int b=2; b<=10; b++) {
				int B = (int)Math.pow(x, b);
				if(B<=X) {
					if(B>ans) {
						ans=B;
					}
				}else{
					break;
				}
			}
		}
		
		System.out.println(ans);	
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int X = Integer.parseInt(br.readLine()); X Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br long ans = 0; ans 0 for(int x=1; x<32; x++) {
			for(int b=2; b<=10; b++) {
				int B = (int)Math.pow(x, b);
				if(B<=X) {
					if(B>ans) {
						ans=B;
					}
				}else{
					break;
				}
			}
		} int x=1; int x=1; x 1 x<32 x 32 x++ x++ x {
			for(int b=2; b<=10; b++) {
				int B = (int)Math.pow(x, b);
				if(B<=X) {
					if(B>ans) {
						ans=B;
					}
				}else{
					break;
				}
			}
		} {
			for(int b=2; b<=10; b++) {
				int B = (int)Math.pow(x, b);
				if(B<=X) {
					if(B>ans) {
						ans=B;
					}
				}else{
					break;
				}
			}
		} for(int b=2; b<=10; b++) {
				int B = (int)Math.pow(x, b);
				if(B<=X) {
					if(B>ans) {
						ans=B;
					}
				}else{
					break;
				}
			} int b=2; int b=2; b 2 b<=10 b 10 b++ b++ b {
				int B = (int)Math.pow(x, b);
				if(B<=X) {
					if(B>ans) {
						ans=B;
					}
				}else{
					break;
				}
			} {
				int B = (int)Math.pow(x, b);
				if(B<=X) {
					if(B>ans) {
						ans=B;
					}
				}else{
					break;
				}
			} int B = (int)Math.pow(x, b); B (int)Math.pow(x, b) Math.pow Math x b if(B<=X) {
					if(B>ans) {
						ans=B;
					}
				}else{
					break;
				} B<=X B X {
					if(B>ans) {
						ans=B;
					}
				} if(B>ans) {
						ans=B;
					} B>ans B ans {
						ans=B;
					} ans=B ans B {
					break;
				} break; System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int X = Integer.parseInt(br.readLine());
		long ans = 0;
		for(int x=1; x<32; x++) {
			for(int b=2; b<=10; b++) {
				int B = (int)Math.pow(x, b);
				if(B<=X) {
					if(B>ans) {
						ans=B;
					}
				}else{
					break;
				}
			}
		}
		
		System.out.println(ans);	
	}
} public class Main {

	public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int X = Integer.parseInt(br.readLine());
		long ans = 0;
		for(int x=1; x<32; x++) {
			for(int b=2; b<=10; b++) {
				int B = (int)Math.pow(x, b);
				if(B<=X) {
					if(B>ans) {
						ans=B;
					}
				}else{
					break;
				}
			}
		}
		
		System.out.println(ans);	
	}
} Main
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int X = Integer.parseInt(br.readLine());
		long ans = 0;
		for(int x=1; x<32; x++) {
			for(int b=2; b<=10; b++) {
				int B = (int)Math.pow(x, b);
				if(B<=X) {
					if(B>ans) {
						ans=B;
					}
				}else{
					break;
				}
			}
		}
		
		System.out.println(ans);	
	}
}