import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

int x= sc.nextInt();
if(x==1){
	System.out.println(1);
}else{
	int ans=1;

	int pre=1;
	for(int i=2; i<=x; i++){
				pre=i;
				while(pre<=x){
						pre=pre*i;
						if(pre<=x && ans<pre){
							ans = pre;
						}
				}
		}
		System.out.println(ans);
	}

	}

} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

int x= sc.nextInt();
if(x==1){
	System.out.println(1);
}else{
	int ans=1;

	int pre=1;
	for(int i=2; i<=x; i++){
				pre=i;
				while(pre<=x){
						pre=pre*i;
						if(pre<=x && ans<pre){
							ans = pre;
						}
				}
		}
		System.out.println(ans);
	}

	}

} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

int x= sc.nextInt();
if(x==1){
	System.out.println(1);
}else{
	int ans=1;

	int pre=1;
	for(int i=2; i<=x; i++){
				pre=i;
				while(pre<=x){
						pre=pre*i;
						if(pre<=x && ans<pre){
							ans = pre;
						}
				}
		}
		System.out.println(ans);
	}

	} main {
		Scanner sc = new Scanner(System.in);

int x= sc.nextInt();
if(x==1){
	System.out.println(1);
}else{
	int ans=1;

	int pre=1;
	for(int i=2; i<=x; i++){
				pre=i;
				while(pre<=x){
						pre=pre*i;
						if(pre<=x && ans<pre){
							ans = pre;
						}
				}
		}
		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 if(x==1){
	System.out.println(1);
}else{
	int ans=1;

	int pre=1;
	for(int i=2; i<=x; i++){
				pre=i;
				while(pre<=x){
						pre=pre*i;
						if(pre<=x && ans<pre){
							ans = pre;
						}
				}
		}
		System.out.println(ans);
	} x==1 x 1 {
	System.out.println(1);
} System.out.println(1) System.out.println System.out System System.out 1 {
	int ans=1;

	int pre=1;
	for(int i=2; i<=x; i++){
				pre=i;
				while(pre<=x){
						pre=pre*i;
						if(pre<=x && ans<pre){
							ans = pre;
						}
				}
		}
		System.out.println(ans);
	} int ans=1; ans 1 int pre=1; pre 1 for(int i=2; i<=x; i++){
				pre=i;
				while(pre<=x){
						pre=pre*i;
						if(pre<=x && ans<pre){
							ans = pre;
						}
				}
		} int i=2; int i=2; i 2 i<=x i x i++ i++ i {
				pre=i;
				while(pre<=x){
						pre=pre*i;
						if(pre<=x && ans<pre){
							ans = pre;
						}
				}
		} {
				pre=i;
				while(pre<=x){
						pre=pre*i;
						if(pre<=x && ans<pre){
							ans = pre;
						}
				}
		} pre=i pre i while(pre<=x){
						pre=pre*i;
						if(pre<=x && ans<pre){
							ans = pre;
						}
				} pre<=x pre x {
						pre=pre*i;
						if(pre<=x && ans<pre){
							ans = pre;
						}
				} pre=pre*i pre pre*i pre i if(pre<=x && ans<pre){
							ans = pre;
						} pre<=x && ans<pre pre<=x pre x ans<pre ans pre {
							ans = pre;
						} ans = pre ans pre 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();
if(x==1){
	System.out.println(1);
}else{
	int ans=1;

	int pre=1;
	for(int i=2; i<=x; i++){
				pre=i;
				while(pre<=x){
						pre=pre*i;
						if(pre<=x && ans<pre){
							ans = pre;
						}
				}
		}
		System.out.println(ans);
	}

	}

} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

int x= sc.nextInt();
if(x==1){
	System.out.println(1);
}else{
	int ans=1;

	int pre=1;
	for(int i=2; i<=x; i++){
				pre=i;
				while(pre<=x){
						pre=pre*i;
						if(pre<=x && ans<pre){
							ans = pre;
						}
				}
		}
		System.out.println(ans);
	}

	}

} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

int x= sc.nextInt();
if(x==1){
	System.out.println(1);
}else{
	int ans=1;

	int pre=1;
	for(int i=2; i<=x; i++){
				pre=i;
				while(pre<=x){
						pre=pre*i;
						if(pre<=x && ans<pre){
							ans = pre;
						}
				}
		}
		System.out.println(ans);
	}

	}

}
