import java.util.Scanner;

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