import java.util.Scanner;

public class Main {

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

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int x = scanner.nextInt(), max = 1;
			for (int i = 2; i <= (int) Math.sqrt(x); i++) {
				int pow = i * i;
				while (pow <= x) {
					max = Math.max(pow, max);
					pow *= i;
				}
			}
			System.out.println(max);
		}
	}
} Main public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int x = scanner.nextInt(), max = 1;
			for (int i = 2; i <= (int) Math.sqrt(x); i++) {
				int pow = i * i;
				while (pow <= x) {
					max = Math.max(pow, max);
					pow *= i;
				}
			}
			System.out.println(max);
		}
	} main {
		try (Scanner scanner = new Scanner(System.in)) {
			int x = scanner.nextInt(), max = 1;
			for (int i = 2; i <= (int) Math.sqrt(x); i++) {
				int pow = i * i;
				while (pow <= x) {
					max = Math.max(pow, max);
					pow *= i;
				}
			}
			System.out.println(max);
		}
	} try (Scanner scanner = new Scanner(System.in)) {
			int x = scanner.nextInt(), max = 1;
			for (int i = 2; i <= (int) Math.sqrt(x); i++) {
				int pow = i * i;
				while (pow <= x) {
					max = Math.max(pow, max);
					pow *= i;
				}
			}
			System.out.println(max);
		} {
			int x = scanner.nextInt(), max = 1;
			for (int i = 2; i <= (int) Math.sqrt(x); i++) {
				int pow = i * i;
				while (pow <= x) {
					max = Math.max(pow, max);
					pow *= i;
				}
			}
			System.out.println(max);
		} Scanner scanner = new Scanner(System.in) Scanner scanner = new Scanner(System.in) new Scanner(System.in) int x = scanner.nextInt() x scanner.nextInt() scanner.nextInt scanner max = 1; max 1 for (int i = 2; i <= (int) Math.sqrt(x); i++) {
				int pow = i * i;
				while (pow <= x) {
					max = Math.max(pow, max);
					pow *= i;
				}
			} int i = 2; int i = 2; i 2 i <= (int) Math.sqrt(x) i (int) Math.sqrt(x) Math.sqrt Math x i++ i++ i {
				int pow = i * i;
				while (pow <= x) {
					max = Math.max(pow, max);
					pow *= i;
				}
			} {
				int pow = i * i;
				while (pow <= x) {
					max = Math.max(pow, max);
					pow *= i;
				}
			} int pow = i * i; pow i * i i i while (pow <= x) {
					max = Math.max(pow, max);
					pow *= i;
				} pow <= x pow x {
					max = Math.max(pow, max);
					pow *= i;
				} max = Math.max(pow, max) max Math.max(pow, max) Math.max Math pow max pow *= i pow i 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) {
		try (Scanner scanner = new Scanner(System.in)) {
			int x = scanner.nextInt(), max = 1;
			for (int i = 2; i <= (int) Math.sqrt(x); i++) {
				int pow = i * i;
				while (pow <= x) {
					max = Math.max(pow, max);
					pow *= i;
				}
			}
			System.out.println(max);
		}
	}
} public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int x = scanner.nextInt(), max = 1;
			for (int i = 2; i <= (int) Math.sqrt(x); i++) {
				int pow = i * i;
				while (pow <= x) {
					max = Math.max(pow, max);
					pow *= i;
				}
			}
			System.out.println(max);
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int x = scanner.nextInt(), max = 1;
			for (int i = 2; i <= (int) Math.sqrt(x); i++) {
				int pow = i * i;
				while (pow <= x) {
					max = Math.max(pow, max);
					pow *= i;
				}
			}
			System.out.println(max);
		}
	}
}
