import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int X =sc.nextInt();

		for(int i=X;i>0;i--) {

			if(i == 1) {
				System.out.println(1);
				return;
			}

			for(int b=(int)Math.sqrt(i)+1;b>2;b--) {
				int temp = i;
				int p = 0;
				while(temp % b == 0) {
					p++;
					temp /= b;
				}

				if(temp == 1 && p > 1) {
					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 X =sc.nextInt();

		for(int i=X;i>0;i--) {

			if(i == 1) {
				System.out.println(1);
				return;
			}

			for(int b=(int)Math.sqrt(i)+1;b>2;b--) {
				int temp = i;
				int p = 0;
				while(temp % b == 0) {
					p++;
					temp /= b;
				}

				if(temp == 1 && p > 1) {
					System.out.println(i);
					return;
				}
			}
		}
	}
} Main public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int X =sc.nextInt();

		for(int i=X;i>0;i--) {

			if(i == 1) {
				System.out.println(1);
				return;
			}

			for(int b=(int)Math.sqrt(i)+1;b>2;b--) {
				int temp = i;
				int p = 0;
				while(temp % b == 0) {
					p++;
					temp /= b;
				}

				if(temp == 1 && p > 1) {
					System.out.println(i);
					return;
				}
			}
		}
	} main {

		Scanner sc = new Scanner(System.in);
		int X =sc.nextInt();

		for(int i=X;i>0;i--) {

			if(i == 1) {
				System.out.println(1);
				return;
			}

			for(int b=(int)Math.sqrt(i)+1;b>2;b--) {
				int temp = i;
				int p = 0;
				while(temp % b == 0) {
					p++;
					temp /= b;
				}

				if(temp == 1 && p > 1) {
					System.out.println(i);
					return;
				}
			}
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X =sc.nextInt(); X sc.nextInt() sc.nextInt sc for(int i=X;i>0;i--) {

			if(i == 1) {
				System.out.println(1);
				return;
			}

			for(int b=(int)Math.sqrt(i)+1;b>2;b--) {
				int temp = i;
				int p = 0;
				while(temp % b == 0) {
					p++;
					temp /= b;
				}

				if(temp == 1 && p > 1) {
					System.out.println(i);
					return;
				}
			}
		} int i=X; int i=X; i X i>0 i 0 i-- i-- i {

			if(i == 1) {
				System.out.println(1);
				return;
			}

			for(int b=(int)Math.sqrt(i)+1;b>2;b--) {
				int temp = i;
				int p = 0;
				while(temp % b == 0) {
					p++;
					temp /= b;
				}

				if(temp == 1 && p > 1) {
					System.out.println(i);
					return;
				}
			}
		} {

			if(i == 1) {
				System.out.println(1);
				return;
			}

			for(int b=(int)Math.sqrt(i)+1;b>2;b--) {
				int temp = i;
				int p = 0;
				while(temp % b == 0) {
					p++;
					temp /= b;
				}

				if(temp == 1 && p > 1) {
					System.out.println(i);
					return;
				}
			}
		} if(i == 1) {
				System.out.println(1);
				return;
			} i == 1 i 1 {
				System.out.println(1);
				return;
			} System.out.println(1) System.out.println System.out System System.out 1 return; for(int b=(int)Math.sqrt(i)+1;b>2;b--) {
				int temp = i;
				int p = 0;
				while(temp % b == 0) {
					p++;
					temp /= b;
				}

				if(temp == 1 && p > 1) {
					System.out.println(i);
					return;
				}
			} int b=(int)Math.sqrt(i)+1; int b=(int)Math.sqrt(i)+1; b (int)Math.sqrt(i)+1 (int)Math.sqrt(i) Math.sqrt Math i 1 b>2 b 2 b-- b-- b {
				int temp = i;
				int p = 0;
				while(temp % b == 0) {
					p++;
					temp /= b;
				}

				if(temp == 1 && p > 1) {
					System.out.println(i);
					return;
				}
			} {
				int temp = i;
				int p = 0;
				while(temp % b == 0) {
					p++;
					temp /= b;
				}

				if(temp == 1 && p > 1) {
					System.out.println(i);
					return;
				}
			} int temp = i; temp i int p = 0; p 0 while(temp % b == 0) {
					p++;
					temp /= b;
				} temp % b == 0 temp % b temp b 0 {
					p++;
					temp /= b;
				} p++ p temp /= b temp b if(temp == 1 && p > 1) {
					System.out.println(i);
					return;
				} temp == 1 && p > 1 temp == 1 temp 1 p > 1 p 1 {
					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 X =sc.nextInt();

		for(int i=X;i>0;i--) {

			if(i == 1) {
				System.out.println(1);
				return;
			}

			for(int b=(int)Math.sqrt(i)+1;b>2;b--) {
				int temp = i;
				int p = 0;
				while(temp % b == 0) {
					p++;
					temp /= b;
				}

				if(temp == 1 && p > 1) {
					System.out.println(i);
					return;
				}
			}
		}
	}
} public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int X =sc.nextInt();

		for(int i=X;i>0;i--) {

			if(i == 1) {
				System.out.println(1);
				return;
			}

			for(int b=(int)Math.sqrt(i)+1;b>2;b--) {
				int temp = i;
				int p = 0;
				while(temp % b == 0) {
					p++;
					temp /= b;
				}

				if(temp == 1 && p > 1) {
					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 X =sc.nextInt();

		for(int i=X;i>0;i--) {

			if(i == 1) {
				System.out.println(1);
				return;
			}

			for(int b=(int)Math.sqrt(i)+1;b>2;b--) {
				int temp = i;
				int p = 0;
				while(temp % b == 0) {
					p++;
					temp /= b;
				}

				if(temp == 1 && p > 1) {
					System.out.println(i);
					return;
				}
			}
		}
	}
}
