import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		
		long max=0;
		for(int i=1;i<=1000;i++) {
			for(int j=2;j<=1000;j++) {
				long tar=(long)Math.pow(i, j);
				if(tar<=x) {
					max=Math.max(max, tar);
				}
			}
		}
		
		System.out.println(max);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		
		long max=0;
		for(int i=1;i<=1000;i++) {
			for(int j=2;j<=1000;j++) {
				long tar=(long)Math.pow(i, j);
				if(tar<=x) {
					max=Math.max(max, tar);
				}
			}
		}
		
		System.out.println(max);
	}
} Main @SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		
		long max=0;
		for(int i=1;i<=1000;i++) {
			for(int j=2;j<=1000;j++) {
				long tar=(long)Math.pow(i, j);
				if(tar<=x) {
					max=Math.max(max, tar);
				}
			}
		}
		
		System.out.println(max);
	} main {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		
		long max=0;
		for(int i=1;i<=1000;i++) {
			for(int j=2;j<=1000;j++) {
				long tar=(long)Math.pow(i, j);
				if(tar<=x) {
					max=Math.max(max, tar);
				}
			}
		}
		
		System.out.println(max);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int x = scanner.nextInt(); x scanner.nextInt() scanner.nextInt scanner long max=0; max 0 for(int i=1;i<=1000;i++) {
			for(int j=2;j<=1000;j++) {
				long tar=(long)Math.pow(i, j);
				if(tar<=x) {
					max=Math.max(max, tar);
				}
			}
		} int i=1; int i=1; i 1 i<=1000 i 1000 i++ i++ i {
			for(int j=2;j<=1000;j++) {
				long tar=(long)Math.pow(i, j);
				if(tar<=x) {
					max=Math.max(max, tar);
				}
			}
		} {
			for(int j=2;j<=1000;j++) {
				long tar=(long)Math.pow(i, j);
				if(tar<=x) {
					max=Math.max(max, tar);
				}
			}
		} for(int j=2;j<=1000;j++) {
				long tar=(long)Math.pow(i, j);
				if(tar<=x) {
					max=Math.max(max, tar);
				}
			} int j=2; int j=2; j 2 j<=1000 j 1000 j++ j++ j {
				long tar=(long)Math.pow(i, j);
				if(tar<=x) {
					max=Math.max(max, tar);
				}
			} {
				long tar=(long)Math.pow(i, j);
				if(tar<=x) {
					max=Math.max(max, tar);
				}
			} long tar=(long)Math.pow(i, j); tar (long)Math.pow(i, j) Math.pow Math i j if(tar<=x) {
					max=Math.max(max, tar);
				} tar<=x tar x {
					max=Math.max(max, tar);
				} max=Math.max(max, tar) max Math.max(max, tar) Math.max Math max tar System.out.println(max) System.out.println System.out System System.out max String args[] args public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		
		long max=0;
		for(int i=1;i<=1000;i++) {
			for(int j=2;j<=1000;j++) {
				long tar=(long)Math.pow(i, j);
				if(tar<=x) {
					max=Math.max(max, tar);
				}
			}
		}
		
		System.out.println(max);
	}
} public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		
		long max=0;
		for(int i=1;i<=1000;i++) {
			for(int j=2;j<=1000;j++) {
				long tar=(long)Math.pow(i, j);
				if(tar<=x) {
					max=Math.max(max, tar);
				}
			}
		}
		
		System.out.println(max);
	}
} Main
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt();
		
		long max=0;
		for(int i=1;i<=1000;i++) {
			for(int j=2;j<=1000;j++) {
				long tar=(long)Math.pow(i, j);
				if(tar<=x) {
					max=Math.max(max, tar);
				}
			}
		}
		
		System.out.println(max);
	}
}
