import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int answer=1;
		int num=1;
		int finNum=(int)Math.sqrt(X);
		for(int b =2 ; b <= 100 && b<=finNum ; b++) {//100^2まで
			for(int p=2; num<=X ;p++) {
				num=bekijyo(b,p);
				if(num>X) {
					num=bekijyo(b,p-1);
					break;
				}
			}
			answer=Math.max(num, answer);
		}
		System.out.println(answer);
	}
	public static int bekijyo(int b , int p) {
		if(p==0)return 0;
		int ret=b;
		for(int a=1 ; a<p ; a++) {
			ret=ret*b;
		}
		return(ret);
	}
} 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 answer=1;
		int num=1;
		int finNum=(int)Math.sqrt(X);
		for(int b =2 ; b <= 100 && b<=finNum ; b++) {//100^2まで
			for(int p=2; num<=X ;p++) {
				num=bekijyo(b,p);
				if(num>X) {
					num=bekijyo(b,p-1);
					break;
				}
			}
			answer=Math.max(num, answer);
		}
		System.out.println(answer);
	}
	public static int bekijyo(int b , int p) {
		if(p==0)return 0;
		int ret=b;
		for(int a=1 ; a<p ; a++) {
			ret=ret*b;
		}
		return(ret);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int answer=1;
		int num=1;
		int finNum=(int)Math.sqrt(X);
		for(int b =2 ; b <= 100 && b<=finNum ; b++) {//100^2まで
			for(int p=2; num<=X ;p++) {
				num=bekijyo(b,p);
				if(num>X) {
					num=bekijyo(b,p-1);
					break;
				}
			}
			answer=Math.max(num, answer);
		}
		System.out.println(answer);
	} main {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int answer=1;
		int num=1;
		int finNum=(int)Math.sqrt(X);
		for(int b =2 ; b <= 100 && b<=finNum ; b++) {//100^2まで
			for(int p=2; num<=X ;p++) {
				num=bekijyo(b,p);
				if(num>X) {
					num=bekijyo(b,p-1);
					break;
				}
			}
			answer=Math.max(num, answer);
		}
		System.out.println(answer);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc int answer=1; answer 1 int num=1; num 1 int finNum=(int)Math.sqrt(X); finNum (int)Math.sqrt(X) Math.sqrt Math X for(int b =2 ; b <= 100 && b<=finNum ; b++) {//100^2まで
			for(int p=2; num<=X ;p++) {
				num=bekijyo(b,p);
				if(num>X) {
					num=bekijyo(b,p-1);
					break;
				}
			}
			answer=Math.max(num, answer);
		} int b =2 ; int b =2 ; b 2 b <= 100 && b<=finNum b <= 100 b 100 b<=finNum b finNum b++ b++ b {//100^2まで
			for(int p=2; num<=X ;p++) {
				num=bekijyo(b,p);
				if(num>X) {
					num=bekijyo(b,p-1);
					break;
				}
			}
			answer=Math.max(num, answer);
		} {//100^2まで
			for(int p=2; num<=X ;p++) {
				num=bekijyo(b,p);
				if(num>X) {
					num=bekijyo(b,p-1);
					break;
				}
			}
			answer=Math.max(num, answer);
		} for(int p=2; num<=X ;p++) {
				num=bekijyo(b,p);
				if(num>X) {
					num=bekijyo(b,p-1);
					break;
				}
			} int p=2; int p=2; p 2 num<=X num X p++ p++ p {
				num=bekijyo(b,p);
				if(num>X) {
					num=bekijyo(b,p-1);
					break;
				}
			} {
				num=bekijyo(b,p);
				if(num>X) {
					num=bekijyo(b,p-1);
					break;
				}
			} num=bekijyo(b,p) num bekijyo(b,p) bekijyo b p if(num>X) {
					num=bekijyo(b,p-1);
					break;
				} num>X num X {
					num=bekijyo(b,p-1);
					break;
				} num=bekijyo(b,p-1) num bekijyo(b,p-1) bekijyo b p-1 p 1 break; answer=Math.max(num, answer) answer Math.max(num, answer) Math.max Math num answer System.out.println(answer) System.out.println System.out System System.out answer String[] args args public static int bekijyo(int b , int p) {
		if(p==0)return 0;
		int ret=b;
		for(int a=1 ; a<p ; a++) {
			ret=ret*b;
		}
		return(ret);
	} bekijyo {
		if(p==0)return 0;
		int ret=b;
		for(int a=1 ; a<p ; a++) {
			ret=ret*b;
		}
		return(ret);
	} if(p==0)return 0; p==0 p 0 return 0; 0 int ret=b; ret b for(int a=1 ; a<p ; a++) {
			ret=ret*b;
		} int a=1 ; int a=1 ; a 1 a<p a p a++ a++ a {
			ret=ret*b;
		} {
			ret=ret*b;
		} ret=ret*b ret ret*b ret b return(ret); (ret) int b b int p p public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int answer=1;
		int num=1;
		int finNum=(int)Math.sqrt(X);
		for(int b =2 ; b <= 100 && b<=finNum ; b++) {//100^2まで
			for(int p=2; num<=X ;p++) {
				num=bekijyo(b,p);
				if(num>X) {
					num=bekijyo(b,p-1);
					break;
				}
			}
			answer=Math.max(num, answer);
		}
		System.out.println(answer);
	}
	public static int bekijyo(int b , int p) {
		if(p==0)return 0;
		int ret=b;
		for(int a=1 ; a<p ; a++) {
			ret=ret*b;
		}
		return(ret);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int answer=1;
		int num=1;
		int finNum=(int)Math.sqrt(X);
		for(int b =2 ; b <= 100 && b<=finNum ; b++) {//100^2まで
			for(int p=2; num<=X ;p++) {
				num=bekijyo(b,p);
				if(num>X) {
					num=bekijyo(b,p-1);
					break;
				}
			}
			answer=Math.max(num, answer);
		}
		System.out.println(answer);
	}
	public static int bekijyo(int b , int p) {
		if(p==0)return 0;
		int ret=b;
		for(int a=1 ; a<p ; a++) {
			ret=ret*b;
		}
		return(ret);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int answer=1;
		int num=1;
		int finNum=(int)Math.sqrt(X);
		for(int b =2 ; b <= 100 && b<=finNum ; b++) {//100^2まで
			for(int p=2; num<=X ;p++) {
				num=bekijyo(b,p);
				if(num>X) {
					num=bekijyo(b,p-1);
					break;
				}
			}
			answer=Math.max(num, answer);
		}
		System.out.println(answer);
	}
	public static int bekijyo(int b , int p) {
		if(p==0)return 0;
		int ret=b;
		for(int a=1 ; a<p ; a++) {
			ret=ret*b;
		}
		return(ret);
	}
}