import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[] = new int[1001];
		for (int i=1;i<=40;i++) {
			for (int j=2;j<=10;j++) {
				int temp = (int) Math.pow(i, j);
				if (temp<=1000) {
					A[temp]++;
				}
			}
		}
		int X= sc.nextInt();
		for (int i=X;i>=0;i--) {
			if (A[i]>0) {
				System.out.println(i);
				return ;
			}
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[] = new int[1001];
		for (int i=1;i<=40;i++) {
			for (int j=2;j<=10;j++) {
				int temp = (int) Math.pow(i, j);
				if (temp<=1000) {
					A[temp]++;
				}
			}
		}
		int X= sc.nextInt();
		for (int i=X;i>=0;i--) {
			if (A[i]>0) {
				System.out.println(i);
				return ;
			}
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[] = new int[1001];
		for (int i=1;i<=40;i++) {
			for (int j=2;j<=10;j++) {
				int temp = (int) Math.pow(i, j);
				if (temp<=1000) {
					A[temp]++;
				}
			}
		}
		int X= sc.nextInt();
		for (int i=X;i>=0;i--) {
			if (A[i]>0) {
				System.out.println(i);
				return ;
			}
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int A[] = new int[1001];
		for (int i=1;i<=40;i++) {
			for (int j=2;j<=10;j++) {
				int temp = (int) Math.pow(i, j);
				if (temp<=1000) {
					A[temp]++;
				}
			}
		}
		int X= sc.nextInt();
		for (int i=X;i>=0;i--) {
			if (A[i]>0) {
				System.out.println(i);
				return ;
			}
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A[] = new int[1001]; A new int[1001] 1001 for (int i=1;i<=40;i++) {
			for (int j=2;j<=10;j++) {
				int temp = (int) Math.pow(i, j);
				if (temp<=1000) {
					A[temp]++;
				}
			}
		} int i=1; int i=1; i 1 i<=40 i 40 i++ i++ i {
			for (int j=2;j<=10;j++) {
				int temp = (int) Math.pow(i, j);
				if (temp<=1000) {
					A[temp]++;
				}
			}
		} {
			for (int j=2;j<=10;j++) {
				int temp = (int) Math.pow(i, j);
				if (temp<=1000) {
					A[temp]++;
				}
			}
		} for (int j=2;j<=10;j++) {
				int temp = (int) Math.pow(i, j);
				if (temp<=1000) {
					A[temp]++;
				}
			} int j=2; int j=2; j 2 j<=10 j 10 j++ j++ j {
				int temp = (int) Math.pow(i, j);
				if (temp<=1000) {
					A[temp]++;
				}
			} {
				int temp = (int) Math.pow(i, j);
				if (temp<=1000) {
					A[temp]++;
				}
			} int temp = (int) Math.pow(i, j); temp (int) Math.pow(i, j) Math.pow Math i j if (temp<=1000) {
					A[temp]++;
				} temp<=1000 temp 1000 {
					A[temp]++;
				} A[temp]++ A[temp] A temp int X= sc.nextInt(); X sc.nextInt() sc.nextInt sc for (int i=X;i>=0;i--) {
			if (A[i]>0) {
				System.out.println(i);
				return ;
			}
		} int i=X; int i=X; i X i>=0 i 0 i-- i-- i {
			if (A[i]>0) {
				System.out.println(i);
				return ;
			}
		} {
			if (A[i]>0) {
				System.out.println(i);
				return ;
			}
		} if (A[i]>0) {
				System.out.println(i);
				return ;
			} A[i]>0 A[i] A i 0 {
				System.out.println(i);
				return ;
			} System.out.println(i) System.out.println System.out System System.out i return ; String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[] = new int[1001];
		for (int i=1;i<=40;i++) {
			for (int j=2;j<=10;j++) {
				int temp = (int) Math.pow(i, j);
				if (temp<=1000) {
					A[temp]++;
				}
			}
		}
		int X= sc.nextInt();
		for (int i=X;i>=0;i--) {
			if (A[i]>0) {
				System.out.println(i);
				return ;
			}
		}
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[] = new int[1001];
		for (int i=1;i<=40;i++) {
			for (int j=2;j<=10;j++) {
				int temp = (int) Math.pow(i, j);
				if (temp<=1000) {
					A[temp]++;
				}
			}
		}
		int X= sc.nextInt();
		for (int i=X;i>=0;i--) {
			if (A[i]>0) {
				System.out.println(i);
				return ;
			}
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[] = new int[1001];
		for (int i=1;i<=40;i++) {
			for (int j=2;j<=10;j++) {
				int temp = (int) Math.pow(i, j);
				if (temp<=1000) {
					A[temp]++;
				}
			}
		}
		int X= sc.nextInt();
		for (int i=X;i>=0;i--) {
			if (A[i]>0) {
				System.out.println(i);
				return ;
			}
		}
	}
}