import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int max = 1;
		for (int i = 2; i <= 100; i++) {
			for (int j = 2; j < 10; j++) {
				int target = (int)Math.pow(i, j);
				if (target > x) {
					break;
				}
				if (target > max) {
					max = target;
				}
			}
		}
		System.out.println(max);
	}
} import java.util.*; util.* java public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int max = 1;
		for (int i = 2; i <= 100; i++) {
			for (int j = 2; j < 10; j++) {
				int target = (int)Math.pow(i, j);
				if (target > x) {
					break;
				}
				if (target > max) {
					max = target;
				}
			}
		}
		System.out.println(max);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int max = 1;
		for (int i = 2; i <= 100; i++) {
			for (int j = 2; j < 10; j++) {
				int target = (int)Math.pow(i, j);
				if (target > x) {
					break;
				}
				if (target > max) {
					max = target;
				}
			}
		}
		System.out.println(max);
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int max = 1;
		for (int i = 2; i <= 100; i++) {
			for (int j = 2; j < 10; j++) {
				int target = (int)Math.pow(i, j);
				if (target > x) {
					break;
				}
				if (target > max) {
					max = target;
				}
			}
		}
		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 for (int i = 2; i <= 100; i++) {
			for (int j = 2; j < 10; j++) {
				int target = (int)Math.pow(i, j);
				if (target > x) {
					break;
				}
				if (target > max) {
					max = target;
				}
			}
		} int i = 2; int i = 2; i 2 i <= 100 i 100 i++ i++ i {
			for (int j = 2; j < 10; j++) {
				int target = (int)Math.pow(i, j);
				if (target > x) {
					break;
				}
				if (target > max) {
					max = target;
				}
			}
		} {
			for (int j = 2; j < 10; j++) {
				int target = (int)Math.pow(i, j);
				if (target > x) {
					break;
				}
				if (target > max) {
					max = target;
				}
			}
		} for (int j = 2; j < 10; j++) {
				int target = (int)Math.pow(i, j);
				if (target > x) {
					break;
				}
				if (target > max) {
					max = target;
				}
			} int j = 2; int j = 2; j 2 j < 10 j 10 j++ j++ j {
				int target = (int)Math.pow(i, j);
				if (target > x) {
					break;
				}
				if (target > max) {
					max = target;
				}
			} {
				int target = (int)Math.pow(i, j);
				if (target > x) {
					break;
				}
				if (target > max) {
					max = target;
				}
			} int target = (int)Math.pow(i, j); target (int)Math.pow(i, j) Math.pow Math i j if (target > x) {
					break;
				} target > x target x {
					break;
				} break; if (target > max) {
					max = target;
				} target > max target max {
					max = target;
				} max = target max target 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;
		for (int i = 2; i <= 100; i++) {
			for (int j = 2; j < 10; j++) {
				int target = (int)Math.pow(i, j);
				if (target > x) {
					break;
				}
				if (target > max) {
					max = target;
				}
			}
		}
		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;
		for (int i = 2; i <= 100; i++) {
			for (int j = 2; j < 10; j++) {
				int target = (int)Math.pow(i, j);
				if (target > x) {
					break;
				}
				if (target > max) {
					max = target;
				}
			}
		}
		System.out.println(max);
	}
} Main
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int max = 1;
		for (int i = 2; i <= 100; i++) {
			for (int j = 2; j < 10; j++) {
				int target = (int)Math.pow(i, j);
				if (target > x) {
					break;
				}
				if (target > max) {
					max = target;
				}
			}
		}
		System.out.println(max);
	}
}
