import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int max = 1;
		for (int i = 2; i <= x; i++) {
			int tmp = i * i;
			while (tmp <= x) {
//				max = Math.max(max, tmp);
				if (tmp > max) {
					max = tmp;
				}
				tmp *= i;
			}
		}
		System.out.println(max);
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int max = 1;
		for (int i = 2; i <= x; i++) {
			int tmp = i * i;
			while (tmp <= x) {
//				max = Math.max(max, tmp);
				if (tmp > max) {
					max = tmp;
				}
				tmp *= i;
			}
		}
		System.out.println(max);
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int max = 1;
		for (int i = 2; i <= x; i++) {
			int tmp = i * i;
			while (tmp <= x) {
//				max = Math.max(max, tmp);
				if (tmp > max) {
					max = tmp;
				}
				tmp *= i;
			}
		}
		System.out.println(max);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int max = 1;
		for (int i = 2; i <= x; i++) {
			int tmp = i * i;
			while (tmp <= x) {
//				max = Math.max(max, tmp);
				if (tmp > max) {
					max = tmp;
				}
				tmp *= i;
			}
		}
		System.out.println(max);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int max = 1; max 1 for (int i = 2; i <= x; i++) {
			int tmp = i * i;
			while (tmp <= x) {
//				max = Math.max(max, tmp);
				if (tmp > max) {
					max = tmp;
				}
				tmp *= i;
			}
		} int i = 2; int i = 2; i 2 i <= x i x i++ i++ i {
			int tmp = i * i;
			while (tmp <= x) {
//				max = Math.max(max, tmp);
				if (tmp > max) {
					max = tmp;
				}
				tmp *= i;
			}
		} {
			int tmp = i * i;
			while (tmp <= x) {
//				max = Math.max(max, tmp);
				if (tmp > max) {
					max = tmp;
				}
				tmp *= i;
			}
		} int tmp = i * i; tmp i * i i i while (tmp <= x) {
//				max = Math.max(max, tmp);
				if (tmp > max) {
					max = tmp;
				}
				tmp *= i;
			} tmp <= x tmp x {
//				max = Math.max(max, tmp);
				if (tmp > max) {
					max = tmp;
				}
				tmp *= i;
			} if (tmp > max) {
					max = tmp;
				} tmp > max tmp max {
					max = tmp;
				} max = tmp max tmp tmp *= i tmp i System.out.println(max) System.out.println System.out System System.out max sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int max = 1;
		for (int i = 2; i <= x; i++) {
			int tmp = i * i;
			while (tmp <= x) {
//				max = Math.max(max, tmp);
				if (tmp > max) {
					max = tmp;
				}
				tmp *= i;
			}
		}
		System.out.println(max);
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int max = 1;
		for (int i = 2; i <= x; i++) {
			int tmp = i * i;
			while (tmp <= x) {
//				max = Math.max(max, tmp);
				if (tmp > max) {
					max = tmp;
				}
				tmp *= i;
			}
		}
		System.out.println(max);
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int max = 1;
		for (int i = 2; i <= x; i++) {
			int tmp = i * i;
			while (tmp <= x) {
//				max = Math.max(max, tmp);
				if (tmp > max) {
					max = tmp;
				}
				tmp *= i;
			}
		}
		System.out.println(max);
		sc.close();
	}
}
