import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		double ans = 0;
		int max = 1;

		if (x==1) {
			System.out.println(x);
			return;
		}

		for (int i=2;i<=x;i++) {
			for (int j=2;j<=10;j++) {
				ans = Math.pow(i, j);
				if ((ans <= x) && (ans > max)) {
						max = (int)ans;
				}
			}
		}

		System.out.println(max);

		scan.close();

	}

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

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		double ans = 0;
		int max = 1;

		if (x==1) {
			System.out.println(x);
			return;
		}

		for (int i=2;i<=x;i++) {
			for (int j=2;j<=10;j++) {
				ans = Math.pow(i, j);
				if ((ans <= x) && (ans > max)) {
						max = (int)ans;
				}
			}
		}

		System.out.println(max);

		scan.close();

	}

} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		double ans = 0;
		int max = 1;

		if (x==1) {
			System.out.println(x);
			return;
		}

		for (int i=2;i<=x;i++) {
			for (int j=2;j<=10;j++) {
				ans = Math.pow(i, j);
				if ((ans <= x) && (ans > max)) {
						max = (int)ans;
				}
			}
		}

		System.out.println(max);

		scan.close();

	} main {

		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		double ans = 0;
		int max = 1;

		if (x==1) {
			System.out.println(x);
			return;
		}

		for (int i=2;i<=x;i++) {
			for (int j=2;j<=10;j++) {
				ans = Math.pow(i, j);
				if ((ans <= x) && (ans > max)) {
						max = (int)ans;
				}
			}
		}

		System.out.println(max);

		scan.close();

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan double ans = 0; ans 0 int max = 1; max 1 if (x==1) {
			System.out.println(x);
			return;
		} x==1 x 1 {
			System.out.println(x);
			return;
		} System.out.println(x) System.out.println System.out System System.out x return; for (int i=2;i<=x;i++) {
			for (int j=2;j<=10;j++) {
				ans = Math.pow(i, j);
				if ((ans <= x) && (ans > max)) {
						max = (int)ans;
				}
			}
		} int i=2; int i=2; i 2 i<=x i x i++ i++ i {
			for (int j=2;j<=10;j++) {
				ans = Math.pow(i, j);
				if ((ans <= x) && (ans > max)) {
						max = (int)ans;
				}
			}
		} {
			for (int j=2;j<=10;j++) {
				ans = Math.pow(i, j);
				if ((ans <= x) && (ans > max)) {
						max = (int)ans;
				}
			}
		} for (int j=2;j<=10;j++) {
				ans = Math.pow(i, j);
				if ((ans <= x) && (ans > max)) {
						max = (int)ans;
				}
			} int j=2; int j=2; j 2 j<=10 j 10 j++ j++ j {
				ans = Math.pow(i, j);
				if ((ans <= x) && (ans > max)) {
						max = (int)ans;
				}
			} {
				ans = Math.pow(i, j);
				if ((ans <= x) && (ans > max)) {
						max = (int)ans;
				}
			} ans = Math.pow(i, j) ans Math.pow(i, j) Math.pow Math i j if ((ans <= x) && (ans > max)) {
						max = (int)ans;
				} (ans <= x) && (ans > max) (ans <= x) ans x (ans > max) ans max {
						max = (int)ans;
				} max = (int)ans max (int)ans System.out.println(max) System.out.println System.out System System.out max scan.close() scan.close scan String[] args args public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		double ans = 0;
		int max = 1;

		if (x==1) {
			System.out.println(x);
			return;
		}

		for (int i=2;i<=x;i++) {
			for (int j=2;j<=10;j++) {
				ans = Math.pow(i, j);
				if ((ans <= x) && (ans > max)) {
						max = (int)ans;
				}
			}
		}

		System.out.println(max);

		scan.close();

	}

} public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		double ans = 0;
		int max = 1;

		if (x==1) {
			System.out.println(x);
			return;
		}

		for (int i=2;i<=x;i++) {
			for (int j=2;j<=10;j++) {
				ans = Math.pow(i, j);
				if ((ans <= x) && (ans > max)) {
						max = (int)ans;
				}
			}
		}

		System.out.println(max);

		scan.close();

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		double ans = 0;
		int max = 1;

		if (x==1) {
			System.out.println(x);
			return;
		}

		for (int i=2;i<=x;i++) {
			for (int j=2;j<=10;j++) {
				ans = Math.pow(i, j);
				if ((ans <= x) && (ans > max)) {
						max = (int)ans;
				}
			}
		}

		System.out.println(max);

		scan.close();

	}

}
