//2019/3/14
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();

		int a = 1;

		int i = 2;

		int[] array;

		if(X==1 || X==2 || X==3) {

			System.out.println(1);

		}else {

			array = new int[1000];

			Arrays.fill(array, 0);

			int index = 0;

			while(true) {

				a = i*i;

				if(a>X) break;

				for(int j=a;j<=X;j*=i) {

					array[index] = j;

					index++;
				}

				i++;
			}

			Arrays.parallelSort(array);

			int ans = array[999];

			System.out.println(ans);
		}
	}
} import java.util.Arrays; Arrays java.util 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();

		int a = 1;

		int i = 2;

		int[] array;

		if(X==1 || X==2 || X==3) {

			System.out.println(1);

		}else {

			array = new int[1000];

			Arrays.fill(array, 0);

			int index = 0;

			while(true) {

				a = i*i;

				if(a>X) break;

				for(int j=a;j<=X;j*=i) {

					array[index] = j;

					index++;
				}

				i++;
			}

			Arrays.parallelSort(array);

			int ans = array[999];

			System.out.println(ans);
		}
	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();

		int a = 1;

		int i = 2;

		int[] array;

		if(X==1 || X==2 || X==3) {

			System.out.println(1);

		}else {

			array = new int[1000];

			Arrays.fill(array, 0);

			int index = 0;

			while(true) {

				a = i*i;

				if(a>X) break;

				for(int j=a;j<=X;j*=i) {

					array[index] = j;

					index++;
				}

				i++;
			}

			Arrays.parallelSort(array);

			int ans = array[999];

			System.out.println(ans);
		}
	} main {

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();

		int a = 1;

		int i = 2;

		int[] array;

		if(X==1 || X==2 || X==3) {

			System.out.println(1);

		}else {

			array = new int[1000];

			Arrays.fill(array, 0);

			int index = 0;

			while(true) {

				a = i*i;

				if(a>X) break;

				for(int j=a;j<=X;j*=i) {

					array[index] = j;

					index++;
				}

				i++;
			}

			Arrays.parallelSort(array);

			int ans = array[999];

			System.out.println(ans);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc int a = 1; a 1 int i = 2; i 2 int[] array; array if(X==1 || X==2 || X==3) {

			System.out.println(1);

		}else {

			array = new int[1000];

			Arrays.fill(array, 0);

			int index = 0;

			while(true) {

				a = i*i;

				if(a>X) break;

				for(int j=a;j<=X;j*=i) {

					array[index] = j;

					index++;
				}

				i++;
			}

			Arrays.parallelSort(array);

			int ans = array[999];

			System.out.println(ans);
		} X==1 || X==2 || X==3 X==1 || X==2 || X==3 X==1 X 1 X==2 X 2 X==3 X 3 {

			System.out.println(1);

		} System.out.println(1) System.out.println System.out System System.out 1 {

			array = new int[1000];

			Arrays.fill(array, 0);

			int index = 0;

			while(true) {

				a = i*i;

				if(a>X) break;

				for(int j=a;j<=X;j*=i) {

					array[index] = j;

					index++;
				}

				i++;
			}

			Arrays.parallelSort(array);

			int ans = array[999];

			System.out.println(ans);
		} array = new int[1000] array new int[1000] 1000 Arrays.fill(array, 0) Arrays.fill Arrays array 0 int index = 0; index 0 while(true) {

				a = i*i;

				if(a>X) break;

				for(int j=a;j<=X;j*=i) {

					array[index] = j;

					index++;
				}

				i++;
			} true {

				a = i*i;

				if(a>X) break;

				for(int j=a;j<=X;j*=i) {

					array[index] = j;

					index++;
				}

				i++;
			} a = i*i a i*i i i if(a>X) break; a>X a X break; for(int j=a;j<=X;j*=i) {

					array[index] = j;

					index++;
				} int j=a; int j=a; j a j<=X j X j*=i j*=i j i {

					array[index] = j;

					index++;
				} {

					array[index] = j;

					index++;
				} array[index] = j array[index] array index j index++ index i++ i Arrays.parallelSort(array) Arrays.parallelSort Arrays array int ans = array[999]; ans array[999] array 999 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();

		int a = 1;

		int i = 2;

		int[] array;

		if(X==1 || X==2 || X==3) {

			System.out.println(1);

		}else {

			array = new int[1000];

			Arrays.fill(array, 0);

			int index = 0;

			while(true) {

				a = i*i;

				if(a>X) break;

				for(int j=a;j<=X;j*=i) {

					array[index] = j;

					index++;
				}

				i++;
			}

			Arrays.parallelSort(array);

			int ans = array[999];

			System.out.println(ans);
		}
	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();

		int a = 1;

		int i = 2;

		int[] array;

		if(X==1 || X==2 || X==3) {

			System.out.println(1);

		}else {

			array = new int[1000];

			Arrays.fill(array, 0);

			int index = 0;

			while(true) {

				a = i*i;

				if(a>X) break;

				for(int j=a;j<=X;j*=i) {

					array[index] = j;

					index++;
				}

				i++;
			}

			Arrays.parallelSort(array);

			int ans = array[999];

			System.out.println(ans);
		}
	}
} Main
//2019/3/14
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();

		int a = 1;

		int i = 2;

		int[] array;

		if(X==1 || X==2 || X==3) {

			System.out.println(1);

		}else {

			array = new int[1000];

			Arrays.fill(array, 0);

			int index = 0;

			while(true) {

				a = i*i;

				if(a>X) break;

				for(int j=a;j<=X;j*=i) {

					array[index] = j;

					index++;
				}

				i++;
			}

			Arrays.parallelSort(array);

			int ans = array[999];

			System.out.println(ans);
		}
	}
}
