import static java.lang.System.*;
import java.util.*;
 
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int x = sc.nextInt();
		TreeSet<Integer> set = new TreeSet<>();
		set.add(1);
		for (int i=2; i<=33; i++) {
			for (int j=2; j<=100; j++) {
				if (Math.pow(i,j) > x) break;
				set.add((int)Math.pow(i,j));
			}
		}
		
		int ans = 1;
		for (Integer n: set) {
			if (n > x) break;
			ans = n;
		}
		out.println(ans);
	}
} import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; import java.util.*; util.* java public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int x = sc.nextInt();
		TreeSet<Integer> set = new TreeSet<>();
		set.add(1);
		for (int i=2; i<=33; i++) {
			for (int j=2; j<=100; j++) {
				if (Math.pow(i,j) > x) break;
				set.add((int)Math.pow(i,j));
			}
		}
		
		int ans = 1;
		for (Integer n: set) {
			if (n > x) break;
			ans = n;
		}
		out.println(ans);
	}
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) public static void main(String[] args) {
		int x = sc.nextInt();
		TreeSet<Integer> set = new TreeSet<>();
		set.add(1);
		for (int i=2; i<=33; i++) {
			for (int j=2; j<=100; j++) {
				if (Math.pow(i,j) > x) break;
				set.add((int)Math.pow(i,j));
			}
		}
		
		int ans = 1;
		for (Integer n: set) {
			if (n > x) break;
			ans = n;
		}
		out.println(ans);
	} main {
		int x = sc.nextInt();
		TreeSet<Integer> set = new TreeSet<>();
		set.add(1);
		for (int i=2; i<=33; i++) {
			for (int j=2; j<=100; j++) {
				if (Math.pow(i,j) > x) break;
				set.add((int)Math.pow(i,j));
			}
		}
		
		int ans = 1;
		for (Integer n: set) {
			if (n > x) break;
			ans = n;
		}
		out.println(ans);
	} int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc TreeSet<Integer> set = new TreeSet<>(); set new TreeSet<>() set.add(1) set.add set 1 for (int i=2; i<=33; i++) {
			for (int j=2; j<=100; j++) {
				if (Math.pow(i,j) > x) break;
				set.add((int)Math.pow(i,j));
			}
		} int i=2; int i=2; i 2 i<=33 i 33 i++ i++ i {
			for (int j=2; j<=100; j++) {
				if (Math.pow(i,j) > x) break;
				set.add((int)Math.pow(i,j));
			}
		} {
			for (int j=2; j<=100; j++) {
				if (Math.pow(i,j) > x) break;
				set.add((int)Math.pow(i,j));
			}
		} for (int j=2; j<=100; j++) {
				if (Math.pow(i,j) > x) break;
				set.add((int)Math.pow(i,j));
			} int j=2; int j=2; j 2 j<=100 j 100 j++ j++ j {
				if (Math.pow(i,j) > x) break;
				set.add((int)Math.pow(i,j));
			} {
				if (Math.pow(i,j) > x) break;
				set.add((int)Math.pow(i,j));
			} if (Math.pow(i,j) > x) break; Math.pow(i,j) > x Math.pow(i,j) Math.pow Math i j x break; set.add((int)Math.pow(i,j)) set.add set (int)Math.pow(i,j) Math.pow Math i j int ans = 1; ans 1 for (Integer n: set) {
			if (n > x) break;
			ans = n;
		} Integer n set {
			if (n > x) break;
			ans = n;
		} {
			if (n > x) break;
			ans = n;
		} if (n > x) break; n > x n x break; ans = n ans n out.println(ans) out.println out ans String[] args args public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int x = sc.nextInt();
		TreeSet<Integer> set = new TreeSet<>();
		set.add(1);
		for (int i=2; i<=33; i++) {
			for (int j=2; j<=100; j++) {
				if (Math.pow(i,j) > x) break;
				set.add((int)Math.pow(i,j));
			}
		}
		
		int ans = 1;
		for (Integer n: set) {
			if (n > x) break;
			ans = n;
		}
		out.println(ans);
	}
} public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int x = sc.nextInt();
		TreeSet<Integer> set = new TreeSet<>();
		set.add(1);
		for (int i=2; i<=33; i++) {
			for (int j=2; j<=100; j++) {
				if (Math.pow(i,j) > x) break;
				set.add((int)Math.pow(i,j));
			}
		}
		
		int ans = 1;
		for (Integer n: set) {
			if (n > x) break;
			ans = n;
		}
		out.println(ans);
	}
} Main
import static java.lang.System.*;
import java.util.*;
 
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int x = sc.nextInt();
		TreeSet<Integer> set = new TreeSet<>();
		set.add(1);
		for (int i=2; i<=33; i++) {
			for (int j=2; j<=100; j++) {
				if (Math.pow(i,j) > x) break;
				set.add((int)Math.pow(i,j));
			}
		}
		
		int ans = 1;
		for (Integer n: set) {
			if (n > x) break;
			ans = n;
		}
		out.println(ans);
	}
}