import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		for(;x>1;x--) {
			for(int i=2;i < x; i++) {

				int n = i*i;
				if(n > x) break;

				while(n <= x) {
					if(n==x) {
						System.out.println(x);
						return;
					}
					n *= i;
				}

			}
		}
		System.out.println(x);
	}
} 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(;x>1;x--) {
			for(int i=2;i < x; i++) {

				int n = i*i;
				if(n > x) break;

				while(n <= x) {
					if(n==x) {
						System.out.println(x);
						return;
					}
					n *= i;
				}

			}
		}
		System.out.println(x);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		for(;x>1;x--) {
			for(int i=2;i < x; i++) {

				int n = i*i;
				if(n > x) break;

				while(n <= x) {
					if(n==x) {
						System.out.println(x);
						return;
					}
					n *= i;
				}

			}
		}
		System.out.println(x);
	} main {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		for(;x>1;x--) {
			for(int i=2;i < x; i++) {

				int n = i*i;
				if(n > x) break;

				while(n <= x) {
					if(n==x) {
						System.out.println(x);
						return;
					}
					n *= i;
				}

			}
		}
		System.out.println(x);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x=sc.nextInt(); x sc.nextInt() sc.nextInt sc for(;x>1;x--) {
			for(int i=2;i < x; i++) {

				int n = i*i;
				if(n > x) break;

				while(n <= x) {
					if(n==x) {
						System.out.println(x);
						return;
					}
					n *= i;
				}

			}
		} ; x>1 x 1 x-- x-- x {
			for(int i=2;i < x; i++) {

				int n = i*i;
				if(n > x) break;

				while(n <= x) {
					if(n==x) {
						System.out.println(x);
						return;
					}
					n *= i;
				}

			}
		} {
			for(int i=2;i < x; i++) {

				int n = i*i;
				if(n > x) break;

				while(n <= x) {
					if(n==x) {
						System.out.println(x);
						return;
					}
					n *= i;
				}

			}
		} for(int i=2;i < x; i++) {

				int n = i*i;
				if(n > x) break;

				while(n <= x) {
					if(n==x) {
						System.out.println(x);
						return;
					}
					n *= i;
				}

			} int i=2; int i=2; i 2 i < x i x i++ i++ i {

				int n = i*i;
				if(n > x) break;

				while(n <= x) {
					if(n==x) {
						System.out.println(x);
						return;
					}
					n *= i;
				}

			} {

				int n = i*i;
				if(n > x) break;

				while(n <= x) {
					if(n==x) {
						System.out.println(x);
						return;
					}
					n *= i;
				}

			} int n = i*i; n i*i i i if(n > x) break; n > x n x break; while(n <= x) {
					if(n==x) {
						System.out.println(x);
						return;
					}
					n *= i;
				} n <= x n x {
					if(n==x) {
						System.out.println(x);
						return;
					}
					n *= i;
				} if(n==x) {
						System.out.println(x);
						return;
					} n==x n x {
						System.out.println(x);
						return;
					} System.out.println(x) System.out.println System.out System System.out x return; n *= i n i System.out.println(x) System.out.println System.out System System.out x String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		for(;x>1;x--) {
			for(int i=2;i < x; i++) {

				int n = i*i;
				if(n > x) break;

				while(n <= x) {
					if(n==x) {
						System.out.println(x);
						return;
					}
					n *= i;
				}

			}
		}
		System.out.println(x);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x=sc.nextInt();
		for(;x>1;x--) {
			for(int i=2;i < x; i++) {

				int n = i*i;
				if(n > x) break;

				while(n <= x) {
					if(n==x) {
						System.out.println(x);
						return;
					}
					n *= i;
				}

			}
		}
		System.out.println(x);
	}
} 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(;x>1;x--) {
			for(int i=2;i < x; i++) {

				int n = i*i;
				if(n > x) break;

				while(n <= x) {
					if(n==x) {
						System.out.println(x);
						return;
					}
					n *= i;
				}

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