
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		//  1 <= x <= 1000
		int x = scanner.nextInt();
		int ans = 0;
		ans = exponential(x);
		System.out.println(ans);
		
	}
	
	public static int exponential(int x) {
		int ans = 0;
		for (int i = 31; i >= 1; i--) {
			for (int j = 9; j >= 2; j--) {
				if (Math.pow((double)i, (double)j) <= x) {
					ans = Math.max(ans, (int)Math.pow((double)i, (double)j));
//					System.out.println(i + "," + j);
				}
			}
		}
		return ans;
	}

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

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		//  1 <= x <= 1000
		int x = scanner.nextInt();
		int ans = 0;
		ans = exponential(x);
		System.out.println(ans);
		
	}
	
	public static int exponential(int x) {
		int ans = 0;
		for (int i = 31; i >= 1; i--) {
			for (int j = 9; j >= 2; j--) {
				if (Math.pow((double)i, (double)j) <= x) {
					ans = Math.max(ans, (int)Math.pow((double)i, (double)j));
//					System.out.println(i + "," + j);
				}
			}
		}
		return ans;
	}

} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		//  1 <= x <= 1000
		int x = scanner.nextInt();
		int ans = 0;
		ans = exponential(x);
		System.out.println(ans);
		
	} main {
		Scanner scanner = new Scanner(System.in);
		
		//  1 <= x <= 1000
		int x = scanner.nextInt();
		int ans = 0;
		ans = exponential(x);
		System.out.println(ans);
		
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int x = scanner.nextInt(); x scanner.nextInt() scanner.nextInt scanner int ans = 0; ans 0 ans = exponential(x) ans exponential(x) exponential x System.out.println(ans) System.out.println System.out System System.out ans String[] args args public static int exponential(int x) {
		int ans = 0;
		for (int i = 31; i >= 1; i--) {
			for (int j = 9; j >= 2; j--) {
				if (Math.pow((double)i, (double)j) <= x) {
					ans = Math.max(ans, (int)Math.pow((double)i, (double)j));
//					System.out.println(i + "," + j);
				}
			}
		}
		return ans;
	} exponential {
		int ans = 0;
		for (int i = 31; i >= 1; i--) {
			for (int j = 9; j >= 2; j--) {
				if (Math.pow((double)i, (double)j) <= x) {
					ans = Math.max(ans, (int)Math.pow((double)i, (double)j));
//					System.out.println(i + "," + j);
				}
			}
		}
		return ans;
	} int ans = 0; ans 0 for (int i = 31; i >= 1; i--) {
			for (int j = 9; j >= 2; j--) {
				if (Math.pow((double)i, (double)j) <= x) {
					ans = Math.max(ans, (int)Math.pow((double)i, (double)j));
//					System.out.println(i + "," + j);
				}
			}
		} int i = 31; int i = 31; i 31 i >= 1 i 1 i-- i-- i {
			for (int j = 9; j >= 2; j--) {
				if (Math.pow((double)i, (double)j) <= x) {
					ans = Math.max(ans, (int)Math.pow((double)i, (double)j));
//					System.out.println(i + "," + j);
				}
			}
		} {
			for (int j = 9; j >= 2; j--) {
				if (Math.pow((double)i, (double)j) <= x) {
					ans = Math.max(ans, (int)Math.pow((double)i, (double)j));
//					System.out.println(i + "," + j);
				}
			}
		} for (int j = 9; j >= 2; j--) {
				if (Math.pow((double)i, (double)j) <= x) {
					ans = Math.max(ans, (int)Math.pow((double)i, (double)j));
//					System.out.println(i + "," + j);
				}
			} int j = 9; int j = 9; j 9 j >= 2 j 2 j-- j-- j {
				if (Math.pow((double)i, (double)j) <= x) {
					ans = Math.max(ans, (int)Math.pow((double)i, (double)j));
//					System.out.println(i + "," + j);
				}
			} {
				if (Math.pow((double)i, (double)j) <= x) {
					ans = Math.max(ans, (int)Math.pow((double)i, (double)j));
//					System.out.println(i + "," + j);
				}
			} if (Math.pow((double)i, (double)j) <= x) {
					ans = Math.max(ans, (int)Math.pow((double)i, (double)j));
//					System.out.println(i + "," + j);
				} Math.pow((double)i, (double)j) <= x Math.pow((double)i, (double)j) Math.pow Math (double)i (double)j x {
					ans = Math.max(ans, (int)Math.pow((double)i, (double)j));
//					System.out.println(i + "," + j);
				} ans = Math.max(ans, (int)Math.pow((double)i, (double)j)) ans Math.max(ans, (int)Math.pow((double)i, (double)j)) Math.max Math ans (int)Math.pow((double)i, (double)j) Math.pow Math (double)i (double)j return ans; ans int x x public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		//  1 <= x <= 1000
		int x = scanner.nextInt();
		int ans = 0;
		ans = exponential(x);
		System.out.println(ans);
		
	}
	
	public static int exponential(int x) {
		int ans = 0;
		for (int i = 31; i >= 1; i--) {
			for (int j = 9; j >= 2; j--) {
				if (Math.pow((double)i, (double)j) <= x) {
					ans = Math.max(ans, (int)Math.pow((double)i, (double)j));
//					System.out.println(i + "," + j);
				}
			}
		}
		return ans;
	}

} public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		//  1 <= x <= 1000
		int x = scanner.nextInt();
		int ans = 0;
		ans = exponential(x);
		System.out.println(ans);
		
	}
	
	public static int exponential(int x) {
		int ans = 0;
		for (int i = 31; i >= 1; i--) {
			for (int j = 9; j >= 2; j--) {
				if (Math.pow((double)i, (double)j) <= x) {
					ans = Math.max(ans, (int)Math.pow((double)i, (double)j));
//					System.out.println(i + "," + j);
				}
			}
		}
		return ans;
	}

} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		//  1 <= x <= 1000
		int x = scanner.nextInt();
		int ans = 0;
		ans = exponential(x);
		System.out.println(ans);
		
	}
	
	public static int exponential(int x) {
		int ans = 0;
		for (int i = 31; i >= 1; i--) {
			for (int j = 9; j >= 2; j--) {
				if (Math.pow((double)i, (double)j) <= x) {
					ans = Math.max(ans, (int)Math.pow((double)i, (double)j));
//					System.out.println(i + "," + j);
				}
			}
		}
		return ans;
	}

}
