import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int x = sc.nextInt();

		if (x == 1) {
			pr.println(1);
		} else {
			int max = 0;
			for (int b = 2; b <= x; b++) {
				int tmp = b * b;
				while (tmp <= x) {
					max = Math.max(max, tmp);
					tmp *= b;
				}
			}

			pr.println(max);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int x = sc.nextInt();

		if (x == 1) {
			pr.println(1);
		} else {
			int max = 0;
			for (int b = 2; b <= x; b++) {
				int tmp = b * b;
				while (tmp <= x) {
					max = Math.max(max, tmp);
					tmp *= b;
				}
			}

			pr.println(max);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
} Main private static Scanner sc; sc private static Printer pr; pr static String INPUT = null; INPUT null private static void solve() {
		int x = sc.nextInt();

		if (x == 1) {
			pr.println(1);
		} else {
			int max = 0;
			for (int b = 2; b <= x; b++) {
				int tmp = b * b;
				while (tmp <= x) {
					max = Math.max(max, tmp);
					tmp *= b;
				}
			}

			pr.println(max);
		}
	} solve {
		int x = sc.nextInt();

		if (x == 1) {
			pr.println(1);
		} else {
			int max = 0;
			for (int b = 2; b <= x; b++) {
				int tmp = b * b;
				while (tmp <= x) {
					max = Math.max(max, tmp);
					tmp *= b;
				}
			}

			pr.println(max);
		}
	} int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc if (x == 1) {
			pr.println(1);
		} else {
			int max = 0;
			for (int b = 2; b <= x; b++) {
				int tmp = b * b;
				while (tmp <= x) {
					max = Math.max(max, tmp);
					tmp *= b;
				}
			}

			pr.println(max);
		} x == 1 x 1 {
			pr.println(1);
		} pr.println(1) pr.println pr 1 {
			int max = 0;
			for (int b = 2; b <= x; b++) {
				int tmp = b * b;
				while (tmp <= x) {
					max = Math.max(max, tmp);
					tmp *= b;
				}
			}

			pr.println(max);
		} int max = 0; max 0 for (int b = 2; b <= x; b++) {
				int tmp = b * b;
				while (tmp <= x) {
					max = Math.max(max, tmp);
					tmp *= b;
				}
			} int b = 2; int b = 2; b 2 b <= x b x b++ b++ b {
				int tmp = b * b;
				while (tmp <= x) {
					max = Math.max(max, tmp);
					tmp *= b;
				}
			} {
				int tmp = b * b;
				while (tmp <= x) {
					max = Math.max(max, tmp);
					tmp *= b;
				}
			} int tmp = b * b; tmp b * b b b while (tmp <= x) {
					max = Math.max(max, tmp);
					tmp *= b;
				} tmp <= x tmp x {
					max = Math.max(max, tmp);
					tmp *= b;
				} max = Math.max(max, tmp) max Math.max(max, tmp) Math.max Math max tmp tmp *= b tmp b pr.println(max) pr.println pr max // ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	} main {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	} sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes())) sc new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes())) pr = new Printer(System.out) pr new Printer(System.out) solve() solve pr.flush() pr.flush pr String[] args args private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	} Printer Printer(OutputStream out) {
			super(out);
		} Printer {
			super(out);
		} super(out) super out OutputStream out out PrintWriter public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int x = sc.nextInt();

		if (x == 1) {
			pr.println(1);
		} else {
			int max = 0;
			for (int b = 2; b <= x; b++) {
				int tmp = b * b;
				while (tmp <= x) {
					max = Math.max(max, tmp);
					tmp *= b;
				}
			}

			pr.println(max);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
} public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int x = sc.nextInt();

		if (x == 1) {
			pr.println(1);
		} else {
			int max = 0;
			for (int b = 2; b <= x; b++) {
				int tmp = b * b;
				while (tmp <= x) {
					max = Math.max(max, tmp);
					tmp *= b;
				}
			}

			pr.println(max);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
} Main
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int x = sc.nextInt();

		if (x == 1) {
			pr.println(1);
		} else {
			int max = 0;
			for (int b = 2; b <= x; b++) {
				int tmp = b * b;
				while (tmp <= x) {
					max = Math.max(max, tmp);
					tmp *= b;
				}
			}

			pr.println(max);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(INPUT == null ? System.in : new ByteArrayInputStream(INPUT.getBytes()));
		pr = new Printer(System.out);

		solve();

//		pr.close();
		pr.flush();
//		sc.close();
	}

	static String INPUT = null;

	private static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}
