import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		int X = Integer.parseInt(in.readLine());
		List<Integer> list = new ArrayList<>();
		list.add(1);
		for (int i = 2; i <= 33; ++i) {
			int base = i;
			int val = i * i;
			while (val <= X) {
				list.add(val);
				val *= base;
			}
		}
		Collections.sort(list);
		Collections.reverse(list);
		for (int i = 0; i < list.size(); ++i) {
			if (list.get(i) <= X) {
				System.out.println(list.get(i));
				return;
			}
		}
	}

	void calc() {
	}

	void showResult() {
	}
} import java.util.*; util.* java import java.util.stream.Collectors; Collectors java.util.stream import java.io.*; io.* java import java.nio.charset.StandardCharsets; StandardCharsets java.nio.charset public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		int X = Integer.parseInt(in.readLine());
		List<Integer> list = new ArrayList<>();
		list.add(1);
		for (int i = 2; i <= 33; ++i) {
			int base = i;
			int val = i * i;
			while (val <= X) {
				list.add(val);
				val *= base;
			}
		}
		Collections.sort(list);
		Collections.reverse(list);
		for (int i = 0; i < list.size(); ++i) {
			if (list.get(i) <= X) {
				System.out.println(list.get(i));
				return;
			}
		}
	}

	void calc() {
	}

	void showResult() {
	}
} Main public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	} main {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	} InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8); reader new InputStreamReader(System.in, StandardCharsets.UTF_8) BufferedReader in = new BufferedReader(reader); in new BufferedReader(reader) Main ins = new Main(in); ins new Main(in) ins.calc() ins.calc ins ins.showResult() ins.showResult ins String[] args args Main(BufferedReader in) throws IOException {
		int X = Integer.parseInt(in.readLine());
		List<Integer> list = new ArrayList<>();
		list.add(1);
		for (int i = 2; i <= 33; ++i) {
			int base = i;
			int val = i * i;
			while (val <= X) {
				list.add(val);
				val *= base;
			}
		}
		Collections.sort(list);
		Collections.reverse(list);
		for (int i = 0; i < list.size(); ++i) {
			if (list.get(i) <= X) {
				System.out.println(list.get(i));
				return;
			}
		}
	} Main {
		int X = Integer.parseInt(in.readLine());
		List<Integer> list = new ArrayList<>();
		list.add(1);
		for (int i = 2; i <= 33; ++i) {
			int base = i;
			int val = i * i;
			while (val <= X) {
				list.add(val);
				val *= base;
			}
		}
		Collections.sort(list);
		Collections.reverse(list);
		for (int i = 0; i < list.size(); ++i) {
			if (list.get(i) <= X) {
				System.out.println(list.get(i));
				return;
			}
		}
	} int X = Integer.parseInt(in.readLine()); X Integer.parseInt(in.readLine()) Integer.parseInt Integer in.readLine() in.readLine in List<Integer> list = new ArrayList<>(); list new ArrayList<>() list.add(1) list.add list 1 for (int i = 2; i <= 33; ++i) {
			int base = i;
			int val = i * i;
			while (val <= X) {
				list.add(val);
				val *= base;
			}
		} int i = 2; int i = 2; i 2 i <= 33 i 33 ++i ++i i {
			int base = i;
			int val = i * i;
			while (val <= X) {
				list.add(val);
				val *= base;
			}
		} {
			int base = i;
			int val = i * i;
			while (val <= X) {
				list.add(val);
				val *= base;
			}
		} int base = i; base i int val = i * i; val i * i i i while (val <= X) {
				list.add(val);
				val *= base;
			} val <= X val X {
				list.add(val);
				val *= base;
			} list.add(val) list.add list val val *= base val base Collections.sort(list) Collections.sort Collections list Collections.reverse(list) Collections.reverse Collections list for (int i = 0; i < list.size(); ++i) {
			if (list.get(i) <= X) {
				System.out.println(list.get(i));
				return;
			}
		} int i = 0; int i = 0; i 0 i < list.size() i list.size() list.size list ++i ++i i {
			if (list.get(i) <= X) {
				System.out.println(list.get(i));
				return;
			}
		} {
			if (list.get(i) <= X) {
				System.out.println(list.get(i));
				return;
			}
		} if (list.get(i) <= X) {
				System.out.println(list.get(i));
				return;
			} list.get(i) <= X list.get(i) list.get list i X {
				System.out.println(list.get(i));
				return;
			} System.out.println(list.get(i)) System.out.println System.out System System.out list.get(i) list.get list i return; BufferedReader in in void calc() {
	} calc {
	} void showResult() {
	} showResult {
	} public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		int X = Integer.parseInt(in.readLine());
		List<Integer> list = new ArrayList<>();
		list.add(1);
		for (int i = 2; i <= 33; ++i) {
			int base = i;
			int val = i * i;
			while (val <= X) {
				list.add(val);
				val *= base;
			}
		}
		Collections.sort(list);
		Collections.reverse(list);
		for (int i = 0; i < list.size(); ++i) {
			if (list.get(i) <= X) {
				System.out.println(list.get(i));
				return;
			}
		}
	}

	void calc() {
	}

	void showResult() {
	}
} public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		int X = Integer.parseInt(in.readLine());
		List<Integer> list = new ArrayList<>();
		list.add(1);
		for (int i = 2; i <= 33; ++i) {
			int base = i;
			int val = i * i;
			while (val <= X) {
				list.add(val);
				val *= base;
			}
		}
		Collections.sort(list);
		Collections.reverse(list);
		for (int i = 0; i < list.size(); ++i) {
			if (list.get(i) <= X) {
				System.out.println(list.get(i));
				return;
			}
		}
	}

	void calc() {
	}

	void showResult() {
	}
} Main
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		int X = Integer.parseInt(in.readLine());
		List<Integer> list = new ArrayList<>();
		list.add(1);
		for (int i = 2; i <= 33; ++i) {
			int base = i;
			int val = i * i;
			while (val <= X) {
				list.add(val);
				val *= base;
			}
		}
		Collections.sort(list);
		Collections.reverse(list);
		for (int i = 0; i < list.size(); ++i) {
			if (list.get(i) <= X) {
				System.out.println(list.get(i));
				return;
			}
		}
	}

	void calc() {
	}

	void showResult() {
	}
}
