import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		scan.close();
		int temp = (int)Math.sqrt(X);
		temp = temp * temp;
		int s = temp;
		int a = 2;
		int cnt = 2;
		boolean flag = true;
		if(temp == 1) {
			System.out.println(1);
			System.exit(0);
		}
		while(flag) {
			int k = (int)Math.pow(a, cnt);
			if(k <= X) {
				if(temp < k) {
					temp = k;
				}
			}else {
				a ++;
				cnt = 1;
			}
			cnt ++;
			if(k == s) {
				break;
			}
		}
		System.out.println(temp);
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		scan.close();
		int temp = (int)Math.sqrt(X);
		temp = temp * temp;
		int s = temp;
		int a = 2;
		int cnt = 2;
		boolean flag = true;
		if(temp == 1) {
			System.out.println(1);
			System.exit(0);
		}
		while(flag) {
			int k = (int)Math.pow(a, cnt);
			if(k <= X) {
				if(temp < k) {
					temp = k;
				}
			}else {
				a ++;
				cnt = 1;
			}
			cnt ++;
			if(k == s) {
				break;
			}
		}
		System.out.println(temp);
	}
} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		scan.close();
		int temp = (int)Math.sqrt(X);
		temp = temp * temp;
		int s = temp;
		int a = 2;
		int cnt = 2;
		boolean flag = true;
		if(temp == 1) {
			System.out.println(1);
			System.exit(0);
		}
		while(flag) {
			int k = (int)Math.pow(a, cnt);
			if(k <= X) {
				if(temp < k) {
					temp = k;
				}
			}else {
				a ++;
				cnt = 1;
			}
			cnt ++;
			if(k == s) {
				break;
			}
		}
		System.out.println(temp);
	} main {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		scan.close();
		int temp = (int)Math.sqrt(X);
		temp = temp * temp;
		int s = temp;
		int a = 2;
		int cnt = 2;
		boolean flag = true;
		if(temp == 1) {
			System.out.println(1);
			System.exit(0);
		}
		while(flag) {
			int k = (int)Math.pow(a, cnt);
			if(k <= X) {
				if(temp < k) {
					temp = k;
				}
			}else {
				a ++;
				cnt = 1;
			}
			cnt ++;
			if(k == s) {
				break;
			}
		}
		System.out.println(temp);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int X = scan.nextInt(); X scan.nextInt() scan.nextInt scan scan.close() scan.close scan int temp = (int)Math.sqrt(X); temp (int)Math.sqrt(X) Math.sqrt Math X temp = temp * temp temp temp * temp temp temp int s = temp; s temp int a = 2; a 2 int cnt = 2; cnt 2 boolean flag = true; flag true if(temp == 1) {
			System.out.println(1);
			System.exit(0);
		} temp == 1 temp 1 {
			System.out.println(1);
			System.exit(0);
		} System.out.println(1) System.out.println System.out System System.out 1 System.exit(0) System.exit System 0 while(flag) {
			int k = (int)Math.pow(a, cnt);
			if(k <= X) {
				if(temp < k) {
					temp = k;
				}
			}else {
				a ++;
				cnt = 1;
			}
			cnt ++;
			if(k == s) {
				break;
			}
		} flag {
			int k = (int)Math.pow(a, cnt);
			if(k <= X) {
				if(temp < k) {
					temp = k;
				}
			}else {
				a ++;
				cnt = 1;
			}
			cnt ++;
			if(k == s) {
				break;
			}
		} int k = (int)Math.pow(a, cnt); k (int)Math.pow(a, cnt) Math.pow Math a cnt if(k <= X) {
				if(temp < k) {
					temp = k;
				}
			}else {
				a ++;
				cnt = 1;
			} k <= X k X {
				if(temp < k) {
					temp = k;
				}
			} if(temp < k) {
					temp = k;
				} temp < k temp k {
					temp = k;
				} temp = k temp k {
				a ++;
				cnt = 1;
			} a ++ a cnt = 1 cnt 1 cnt ++ cnt if(k == s) {
				break;
			} k == s k s {
				break;
			} break; System.out.println(temp) System.out.println System.out System System.out temp String[] args args public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		scan.close();
		int temp = (int)Math.sqrt(X);
		temp = temp * temp;
		int s = temp;
		int a = 2;
		int cnt = 2;
		boolean flag = true;
		if(temp == 1) {
			System.out.println(1);
			System.exit(0);
		}
		while(flag) {
			int k = (int)Math.pow(a, cnt);
			if(k <= X) {
				if(temp < k) {
					temp = k;
				}
			}else {
				a ++;
				cnt = 1;
			}
			cnt ++;
			if(k == s) {
				break;
			}
		}
		System.out.println(temp);
	}
} public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		scan.close();
		int temp = (int)Math.sqrt(X);
		temp = temp * temp;
		int s = temp;
		int a = 2;
		int cnt = 2;
		boolean flag = true;
		if(temp == 1) {
			System.out.println(1);
			System.exit(0);
		}
		while(flag) {
			int k = (int)Math.pow(a, cnt);
			if(k <= X) {
				if(temp < k) {
					temp = k;
				}
			}else {
				a ++;
				cnt = 1;
			}
			cnt ++;
			if(k == s) {
				break;
			}
		}
		System.out.println(temp);
	}
} Main
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		scan.close();
		int temp = (int)Math.sqrt(X);
		temp = temp * temp;
		int s = temp;
		int a = 2;
		int cnt = 2;
		boolean flag = true;
		if(temp == 1) {
			System.out.println(1);
			System.exit(0);
		}
		while(flag) {
			int k = (int)Math.pow(a, cnt);
			if(k <= X) {
				if(temp < k) {
					temp = k;
				}
			}else {
				a ++;
				cnt = 1;
			}
			cnt ++;
			if(k == s) {
				break;
			}
		}
		System.out.println(temp);
	}
}
