import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = Integer.parseInt(sc.next());
		sc.close();


		int ans = Integer.MIN_VALUE;
		if(X < 4) {
			System.out.println(1);
			return;
		}else {
			for(int i = 2; i <= X; i++) {
				int j = 2;
				int tmp = (int) Math.pow(i, j);
				while(tmp <= X) {
					j++;
					tmp = (int) Math.pow(i, j);
				}
				tmp = (int) Math.pow(i, j - 1);
				if(ans < tmp && j > 2) {
					ans = tmp;
				}
			}
			System.out.println(ans);
		}

	}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = Integer.parseInt(sc.next());
		sc.close();


		int ans = Integer.MIN_VALUE;
		if(X < 4) {
			System.out.println(1);
			return;
		}else {
			for(int i = 2; i <= X; i++) {
				int j = 2;
				int tmp = (int) Math.pow(i, j);
				while(tmp <= X) {
					j++;
					tmp = (int) Math.pow(i, j);
				}
				tmp = (int) Math.pow(i, j - 1);
				if(ans < tmp && j > 2) {
					ans = tmp;
				}
			}
			System.out.println(ans);
		}

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = Integer.parseInt(sc.next());
		sc.close();


		int ans = Integer.MIN_VALUE;
		if(X < 4) {
			System.out.println(1);
			return;
		}else {
			for(int i = 2; i <= X; i++) {
				int j = 2;
				int tmp = (int) Math.pow(i, j);
				while(tmp <= X) {
					j++;
					tmp = (int) Math.pow(i, j);
				}
				tmp = (int) Math.pow(i, j - 1);
				if(ans < tmp && j > 2) {
					ans = tmp;
				}
			}
			System.out.println(ans);
		}

	} main {
		Scanner sc = new Scanner(System.in);
		int X = Integer.parseInt(sc.next());
		sc.close();


		int ans = Integer.MIN_VALUE;
		if(X < 4) {
			System.out.println(1);
			return;
		}else {
			for(int i = 2; i <= X; i++) {
				int j = 2;
				int tmp = (int) Math.pow(i, j);
				while(tmp <= X) {
					j++;
					tmp = (int) Math.pow(i, j);
				}
				tmp = (int) Math.pow(i, j - 1);
				if(ans < tmp && j > 2) {
					ans = tmp;
				}
			}
			System.out.println(ans);
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = Integer.parseInt(sc.next()); X Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc sc.close() sc.close sc int ans = Integer.MIN_VALUE; ans Integer.MIN_VALUE Integer Integer.MIN_VALUE if(X < 4) {
			System.out.println(1);
			return;
		}else {
			for(int i = 2; i <= X; i++) {
				int j = 2;
				int tmp = (int) Math.pow(i, j);
				while(tmp <= X) {
					j++;
					tmp = (int) Math.pow(i, j);
				}
				tmp = (int) Math.pow(i, j - 1);
				if(ans < tmp && j > 2) {
					ans = tmp;
				}
			}
			System.out.println(ans);
		} X < 4 X 4 {
			System.out.println(1);
			return;
		} System.out.println(1) System.out.println System.out System System.out 1 return; {
			for(int i = 2; i <= X; i++) {
				int j = 2;
				int tmp = (int) Math.pow(i, j);
				while(tmp <= X) {
					j++;
					tmp = (int) Math.pow(i, j);
				}
				tmp = (int) Math.pow(i, j - 1);
				if(ans < tmp && j > 2) {
					ans = tmp;
				}
			}
			System.out.println(ans);
		} for(int i = 2; i <= X; i++) {
				int j = 2;
				int tmp = (int) Math.pow(i, j);
				while(tmp <= X) {
					j++;
					tmp = (int) Math.pow(i, j);
				}
				tmp = (int) Math.pow(i, j - 1);
				if(ans < tmp && j > 2) {
					ans = tmp;
				}
			} int i = 2; int i = 2; i 2 i <= X i X i++ i++ i {
				int j = 2;
				int tmp = (int) Math.pow(i, j);
				while(tmp <= X) {
					j++;
					tmp = (int) Math.pow(i, j);
				}
				tmp = (int) Math.pow(i, j - 1);
				if(ans < tmp && j > 2) {
					ans = tmp;
				}
			} {
				int j = 2;
				int tmp = (int) Math.pow(i, j);
				while(tmp <= X) {
					j++;
					tmp = (int) Math.pow(i, j);
				}
				tmp = (int) Math.pow(i, j - 1);
				if(ans < tmp && j > 2) {
					ans = tmp;
				}
			} int j = 2; j 2 int tmp = (int) Math.pow(i, j); tmp (int) Math.pow(i, j) Math.pow Math i j while(tmp <= X) {
					j++;
					tmp = (int) Math.pow(i, j);
				} tmp <= X tmp X {
					j++;
					tmp = (int) Math.pow(i, j);
				} j++ j tmp = (int) Math.pow(i, j) tmp (int) Math.pow(i, j) Math.pow Math i j tmp = (int) Math.pow(i, j - 1) tmp (int) Math.pow(i, j - 1) Math.pow Math i j - 1 j 1 if(ans < tmp && j > 2) {
					ans = tmp;
				} ans < tmp && j > 2 ans < tmp ans tmp j > 2 j 2 {
					ans = tmp;
				} ans = tmp ans tmp 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) {
		Scanner sc = new Scanner(System.in);
		int X = Integer.parseInt(sc.next());
		sc.close();


		int ans = Integer.MIN_VALUE;
		if(X < 4) {
			System.out.println(1);
			return;
		}else {
			for(int i = 2; i <= X; i++) {
				int j = 2;
				int tmp = (int) Math.pow(i, j);
				while(tmp <= X) {
					j++;
					tmp = (int) Math.pow(i, j);
				}
				tmp = (int) Math.pow(i, j - 1);
				if(ans < tmp && j > 2) {
					ans = tmp;
				}
			}
			System.out.println(ans);
		}

	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = Integer.parseInt(sc.next());
		sc.close();


		int ans = Integer.MIN_VALUE;
		if(X < 4) {
			System.out.println(1);
			return;
		}else {
			for(int i = 2; i <= X; i++) {
				int j = 2;
				int tmp = (int) Math.pow(i, j);
				while(tmp <= X) {
					j++;
					tmp = (int) Math.pow(i, j);
				}
				tmp = (int) Math.pow(i, j - 1);
				if(ans < tmp && j > 2) {
					ans = tmp;
				}
			}
			System.out.println(ans);
		}

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = Integer.parseInt(sc.next());
		sc.close();


		int ans = Integer.MIN_VALUE;
		if(X < 4) {
			System.out.println(1);
			return;
		}else {
			for(int i = 2; i <= X; i++) {
				int j = 2;
				int tmp = (int) Math.pow(i, j);
				while(tmp <= X) {
					j++;
					tmp = (int) Math.pow(i, j);
				}
				tmp = (int) Math.pow(i, j - 1);
				if(ans < tmp && j > 2) {
					ans = tmp;
				}
			}
			System.out.println(ans);
		}

	}

}