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*i<=X;i++) {
			for(int j=i*i;j<=X;j*=i) {
				ans=Math.max(ans,j);
			}
		}
		System.out.println(ans);
		sc.close();
	}
} 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*i<=X;i++) {
			for(int j=i*i;j<=X;j*=i) {
				ans=Math.max(ans,j);
			}
		}
		System.out.println(ans);
		sc.close();
	}
} 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*i<=X;i++) {
			for(int j=i*i;j<=X;j*=i) {
				ans=Math.max(ans,j);
			}
		}
		System.out.println(ans);
		sc.close();
	} main {

		Scanner sc=new Scanner(System.in);
		int X=sc.nextInt();
		int ans=1;
		for(int i=2;i*i<=X;i++) {
			for(int j=i*i;j<=X;j*=i) {
				ans=Math.max(ans,j);
			}
		}
		System.out.println(ans);
		sc.close();
	} 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*i<=X;i++) {
			for(int j=i*i;j<=X;j*=i) {
				ans=Math.max(ans,j);
			}
		} int i=2; int i=2; i 2 i*i<=X i*i i i X i++ i++ i {
			for(int j=i*i;j<=X;j*=i) {
				ans=Math.max(ans,j);
			}
		} {
			for(int j=i*i;j<=X;j*=i) {
				ans=Math.max(ans,j);
			}
		} for(int j=i*i;j<=X;j*=i) {
				ans=Math.max(ans,j);
			} int j=i*i; int j=i*i; j i*i i i j<=X j X j*=i j*=i j i {
				ans=Math.max(ans,j);
			} {
				ans=Math.max(ans,j);
			} ans=Math.max(ans,j) ans Math.max(ans,j) Math.max Math ans j System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc 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*i<=X;i++) {
			for(int j=i*i;j<=X;j*=i) {
				ans=Math.max(ans,j);
			}
		}
		System.out.println(ans);
		sc.close();
	}
} 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*i<=X;i++) {
			for(int j=i*i;j<=X;j*=i) {
				ans=Math.max(ans,j);
			}
		}
		System.out.println(ans);
		sc.close();
	}
} 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*i<=X;i++) {
			for(int j=i*i;j<=X;j*=i) {
				ans=Math.max(ans,j);
			}
		}
		System.out.println(ans);
		sc.close();
	}
}