import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// 標準入力
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int x = Integer.parseInt(br.readLine());

		int ans = 1;

		for (int i = 1; i <= 1000; i++) {
			for (int j = 2; j < 1000; j++) {
				int anstemp = (int) Math.pow(i, j);
				if (x < anstemp) {
					break;
				}
				if (ans < anstemp) {
					ans = anstemp;
				}
			}
		}

		System.out.println(ans);

	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// 標準入力
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int x = Integer.parseInt(br.readLine());

		int ans = 1;

		for (int i = 1; i <= 1000; i++) {
			for (int j = 2; j < 1000; j++) {
				int anstemp = (int) Math.pow(i, j);
				if (x < anstemp) {
					break;
				}
				if (ans < anstemp) {
					ans = anstemp;
				}
			}
		}

		System.out.println(ans);

	}

} Main public static void main(String[] args) throws NumberFormatException, IOException {
		// 標準入力
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int x = Integer.parseInt(br.readLine());

		int ans = 1;

		for (int i = 1; i <= 1000; i++) {
			for (int j = 2; j < 1000; j++) {
				int anstemp = (int) Math.pow(i, j);
				if (x < anstemp) {
					break;
				}
				if (ans < anstemp) {
					ans = anstemp;
				}
			}
		}

		System.out.println(ans);

	} main {
		// 標準入力
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int x = Integer.parseInt(br.readLine());

		int ans = 1;

		for (int i = 1; i <= 1000; i++) {
			for (int j = 2; j < 1000; j++) {
				int anstemp = (int) Math.pow(i, j);
				if (x < anstemp) {
					break;
				}
				if (ans < anstemp) {
					ans = anstemp;
				}
			}
		}

		System.out.println(ans);

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int x = Integer.parseInt(br.readLine()); x Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int ans = 1; ans 1 for (int i = 1; i <= 1000; i++) {
			for (int j = 2; j < 1000; j++) {
				int anstemp = (int) Math.pow(i, j);
				if (x < anstemp) {
					break;
				}
				if (ans < anstemp) {
					ans = anstemp;
				}
			}
		} int i = 1; int i = 1; i 1 i <= 1000 i 1000 i++ i++ i {
			for (int j = 2; j < 1000; j++) {
				int anstemp = (int) Math.pow(i, j);
				if (x < anstemp) {
					break;
				}
				if (ans < anstemp) {
					ans = anstemp;
				}
			}
		} {
			for (int j = 2; j < 1000; j++) {
				int anstemp = (int) Math.pow(i, j);
				if (x < anstemp) {
					break;
				}
				if (ans < anstemp) {
					ans = anstemp;
				}
			}
		} for (int j = 2; j < 1000; j++) {
				int anstemp = (int) Math.pow(i, j);
				if (x < anstemp) {
					break;
				}
				if (ans < anstemp) {
					ans = anstemp;
				}
			} int j = 2; int j = 2; j 2 j < 1000 j 1000 j++ j++ j {
				int anstemp = (int) Math.pow(i, j);
				if (x < anstemp) {
					break;
				}
				if (ans < anstemp) {
					ans = anstemp;
				}
			} {
				int anstemp = (int) Math.pow(i, j);
				if (x < anstemp) {
					break;
				}
				if (ans < anstemp) {
					ans = anstemp;
				}
			} int anstemp = (int) Math.pow(i, j); anstemp (int) Math.pow(i, j) Math.pow Math i j if (x < anstemp) {
					break;
				} x < anstemp x anstemp {
					break;
				} break; if (ans < anstemp) {
					ans = anstemp;
				} ans < anstemp ans anstemp {
					ans = anstemp;
				} ans = anstemp ans anstemp 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) throws NumberFormatException, IOException {
		// 標準入力
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int x = Integer.parseInt(br.readLine());

		int ans = 1;

		for (int i = 1; i <= 1000; i++) {
			for (int j = 2; j < 1000; j++) {
				int anstemp = (int) Math.pow(i, j);
				if (x < anstemp) {
					break;
				}
				if (ans < anstemp) {
					ans = anstemp;
				}
			}
		}

		System.out.println(ans);

	}

} public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// 標準入力
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int x = Integer.parseInt(br.readLine());

		int ans = 1;

		for (int i = 1; i <= 1000; i++) {
			for (int j = 2; j < 1000; j++) {
				int anstemp = (int) Math.pow(i, j);
				if (x < anstemp) {
					break;
				}
				if (ans < anstemp) {
					ans = anstemp;
				}
			}
		}

		System.out.println(ans);

	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// 標準入力
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int x = Integer.parseInt(br.readLine());

		int ans = 1;

		for (int i = 1; i <= 1000; i++) {
			for (int j = 2; j < 1000; j++) {
				int anstemp = (int) Math.pow(i, j);
				if (x < anstemp) {
					break;
				}
				if (ans < anstemp) {
					ans = anstemp;
				}
			}
		}

		System.out.println(ans);

	}

}
