import java.util.Scanner;

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