import java.util.Scanner;

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