import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 1;

		for (int i = 2; i <= Math.sqrt(n); i++) {
			int j = 2;
			int m = (int) Math.pow(i, j);
			while (m <= n) {
				m = (int) Math.pow(i, j);
				if (max < m && m <= n) max = m;
				j++;
			}
		}

		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 n = sc.nextInt();
		int max = 1;

		for (int i = 2; i <= Math.sqrt(n); i++) {
			int j = 2;
			int m = (int) Math.pow(i, j);
			while (m <= n) {
				m = (int) Math.pow(i, j);
				if (max < m && m <= n) max = m;
				j++;
			}
		}

		System.out.println(max);

		sc.close();
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 1;

		for (int i = 2; i <= Math.sqrt(n); i++) {
			int j = 2;
			int m = (int) Math.pow(i, j);
			while (m <= n) {
				m = (int) Math.pow(i, j);
				if (max < m && m <= n) max = m;
				j++;
			}
		}

		System.out.println(max);

		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 1;

		for (int i = 2; i <= Math.sqrt(n); i++) {
			int j = 2;
			int m = (int) Math.pow(i, j);
			while (m <= n) {
				m = (int) Math.pow(i, j);
				if (max < m && m <= n) max = m;
				j++;
			}
		}

		System.out.println(max);

		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int max = 1; max 1 for (int i = 2; i <= Math.sqrt(n); i++) {
			int j = 2;
			int m = (int) Math.pow(i, j);
			while (m <= n) {
				m = (int) Math.pow(i, j);
				if (max < m && m <= n) max = m;
				j++;
			}
		} int i = 2; int i = 2; i 2 i <= Math.sqrt(n) i Math.sqrt(n) Math.sqrt Math n i++ i++ i {
			int j = 2;
			int m = (int) Math.pow(i, j);
			while (m <= n) {
				m = (int) Math.pow(i, j);
				if (max < m && m <= n) max = m;
				j++;
			}
		} {
			int j = 2;
			int m = (int) Math.pow(i, j);
			while (m <= n) {
				m = (int) Math.pow(i, j);
				if (max < m && m <= n) max = m;
				j++;
			}
		} int j = 2; j 2 int m = (int) Math.pow(i, j); m (int) Math.pow(i, j) Math.pow Math i j while (m <= n) {
				m = (int) Math.pow(i, j);
				if (max < m && m <= n) max = m;
				j++;
			} m <= n m n {
				m = (int) Math.pow(i, j);
				if (max < m && m <= n) max = m;
				j++;
			} m = (int) Math.pow(i, j) m (int) Math.pow(i, j) Math.pow Math i j if (max < m && m <= n) max = m; max < m && m <= n max < m max m m <= n m n max = m max m j++ j 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 n = sc.nextInt();
		int max = 1;

		for (int i = 2; i <= Math.sqrt(n); i++) {
			int j = 2;
			int m = (int) Math.pow(i, j);
			while (m <= n) {
				m = (int) Math.pow(i, j);
				if (max < m && m <= n) max = m;
				j++;
			}
		}

		System.out.println(max);

		sc.close();
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 1;

		for (int i = 2; i <= Math.sqrt(n); i++) {
			int j = 2;
			int m = (int) Math.pow(i, j);
			while (m <= n) {
				m = (int) Math.pow(i, j);
				if (max < m && m <= n) max = m;
				j++;
			}
		}

		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 n = sc.nextInt();
		int max = 1;

		for (int i = 2; i <= Math.sqrt(n); i++) {
			int j = 2;
			int m = (int) Math.pow(i, j);
			while (m <= n) {
				m = (int) Math.pow(i, j);
				if (max < m && m <= n) max = m;
				j++;
			}
		}

		System.out.println(max);

		sc.close();
	}

}
