import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		list.add(1);
		for (int i = 2; i <= 31; i++) {
			for (int j = 2; j <= 9; j++) {
				if (Math.pow(i, j) <= 1000) {
					list.add((int) Math.pow(i, j));
				} else break;
			}
		}
		List<Integer> hashlist = new ArrayList<>(new HashSet<>(list));
		Collections.sort(hashlist);
		for (int i = 0; i < hashlist.size(); i++) {
			if (x == 1000) {
				System.out.println(1000); return;
			}
			if (hashlist.get(i) > x) {
				System.out.println(hashlist.get(i-1)); return;
			}
		}
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.HashSet; HashSet java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		list.add(1);
		for (int i = 2; i <= 31; i++) {
			for (int j = 2; j <= 9; j++) {
				if (Math.pow(i, j) <= 1000) {
					list.add((int) Math.pow(i, j));
				} else break;
			}
		}
		List<Integer> hashlist = new ArrayList<>(new HashSet<>(list));
		Collections.sort(hashlist);
		for (int i = 0; i < hashlist.size(); i++) {
			if (x == 1000) {
				System.out.println(1000); return;
			}
			if (hashlist.get(i) > x) {
				System.out.println(hashlist.get(i-1)); return;
			}
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		list.add(1);
		for (int i = 2; i <= 31; i++) {
			for (int j = 2; j <= 9; j++) {
				if (Math.pow(i, j) <= 1000) {
					list.add((int) Math.pow(i, j));
				} else break;
			}
		}
		List<Integer> hashlist = new ArrayList<>(new HashSet<>(list));
		Collections.sort(hashlist);
		for (int i = 0; i < hashlist.size(); i++) {
			if (x == 1000) {
				System.out.println(1000); return;
			}
			if (hashlist.get(i) > x) {
				System.out.println(hashlist.get(i-1)); return;
			}
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		list.add(1);
		for (int i = 2; i <= 31; i++) {
			for (int j = 2; j <= 9; j++) {
				if (Math.pow(i, j) <= 1000) {
					list.add((int) Math.pow(i, j));
				} else break;
			}
		}
		List<Integer> hashlist = new ArrayList<>(new HashSet<>(list));
		Collections.sort(hashlist);
		for (int i = 0; i < hashlist.size(); i++) {
			if (x == 1000) {
				System.out.println(1000); return;
			}
			if (hashlist.get(i) > x) {
				System.out.println(hashlist.get(i-1)); return;
			}
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc List<Integer> list = new ArrayList<>(); list new ArrayList<>() list.add(1) list.add list 1 for (int i = 2; i <= 31; i++) {
			for (int j = 2; j <= 9; j++) {
				if (Math.pow(i, j) <= 1000) {
					list.add((int) Math.pow(i, j));
				} else break;
			}
		} int i = 2; int i = 2; i 2 i <= 31 i 31 i++ i++ i {
			for (int j = 2; j <= 9; j++) {
				if (Math.pow(i, j) <= 1000) {
					list.add((int) Math.pow(i, j));
				} else break;
			}
		} {
			for (int j = 2; j <= 9; j++) {
				if (Math.pow(i, j) <= 1000) {
					list.add((int) Math.pow(i, j));
				} else break;
			}
		} for (int j = 2; j <= 9; j++) {
				if (Math.pow(i, j) <= 1000) {
					list.add((int) Math.pow(i, j));
				} else break;
			} int j = 2; int j = 2; j 2 j <= 9 j 9 j++ j++ j {
				if (Math.pow(i, j) <= 1000) {
					list.add((int) Math.pow(i, j));
				} else break;
			} {
				if (Math.pow(i, j) <= 1000) {
					list.add((int) Math.pow(i, j));
				} else break;
			} if (Math.pow(i, j) <= 1000) {
					list.add((int) Math.pow(i, j));
				} else break; Math.pow(i, j) <= 1000 Math.pow(i, j) Math.pow Math i j 1000 {
					list.add((int) Math.pow(i, j));
				} list.add((int) Math.pow(i, j)) list.add list (int) Math.pow(i, j) Math.pow Math i j break; List<Integer> hashlist = new ArrayList<>(new HashSet<>(list)); hashlist new ArrayList<>(new HashSet<>(list)) Collections.sort(hashlist) Collections.sort Collections hashlist for (int i = 0; i < hashlist.size(); i++) {
			if (x == 1000) {
				System.out.println(1000); return;
			}
			if (hashlist.get(i) > x) {
				System.out.println(hashlist.get(i-1)); return;
			}
		} int i = 0; int i = 0; i 0 i < hashlist.size() i hashlist.size() hashlist.size hashlist i++ i++ i {
			if (x == 1000) {
				System.out.println(1000); return;
			}
			if (hashlist.get(i) > x) {
				System.out.println(hashlist.get(i-1)); return;
			}
		} {
			if (x == 1000) {
				System.out.println(1000); return;
			}
			if (hashlist.get(i) > x) {
				System.out.println(hashlist.get(i-1)); return;
			}
		} if (x == 1000) {
				System.out.println(1000); return;
			} x == 1000 x 1000 {
				System.out.println(1000); return;
			} System.out.println(1000) System.out.println System.out System System.out 1000 return; if (hashlist.get(i) > x) {
				System.out.println(hashlist.get(i-1)); return;
			} hashlist.get(i) > x hashlist.get(i) hashlist.get hashlist i x {
				System.out.println(hashlist.get(i-1)); return;
			} System.out.println(hashlist.get(i-1)) System.out.println System.out System System.out hashlist.get(i-1) hashlist.get hashlist i-1 i 1 return; String[] args args
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		list.add(1);
		for (int i = 2; i <= 31; i++) {
			for (int j = 2; j <= 9; j++) {
				if (Math.pow(i, j) <= 1000) {
					list.add((int) Math.pow(i, j));
				} else break;
			}
		}
		List<Integer> hashlist = new ArrayList<>(new HashSet<>(list));
		Collections.sort(hashlist);
		for (int i = 0; i < hashlist.size(); i++) {
			if (x == 1000) {
				System.out.println(1000); return;
			}
			if (hashlist.get(i) > x) {
				System.out.println(hashlist.get(i-1)); return;
			}
		}
	}
}