import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();

		if(x == 1){
			System.out.println(1);
			return;
		}

		int result = 0;
		for(int i = (int) Math.sqrt(x); i > 1; i--){
			int max = 0;
			int j = i;
			while(max <= x ){
				j *= i;
				if(j > x) break;
				if(max < j) max = j;
			}
			if(result < max) result = max;
		}
		System.out.println(result);
	}
} 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();

		if(x == 1){
			System.out.println(1);
			return;
		}

		int result = 0;
		for(int i = (int) Math.sqrt(x); i > 1; i--){
			int max = 0;
			int j = i;
			while(max <= x ){
				j *= i;
				if(j > x) break;
				if(max < j) max = j;
			}
			if(result < max) result = max;
		}
		System.out.println(result);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();

		if(x == 1){
			System.out.println(1);
			return;
		}

		int result = 0;
		for(int i = (int) Math.sqrt(x); i > 1; i--){
			int max = 0;
			int j = i;
			while(max <= x ){
				j *= i;
				if(j > x) break;
				if(max < j) max = j;
			}
			if(result < max) result = max;
		}
		System.out.println(result);
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();

		if(x == 1){
			System.out.println(1);
			return;
		}

		int result = 0;
		for(int i = (int) Math.sqrt(x); i > 1; i--){
			int max = 0;
			int j = i;
			while(max <= x ){
				j *= i;
				if(j > x) break;
				if(max < j) max = j;
			}
			if(result < max) result = max;
		}
		System.out.println(result);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc if(x == 1){
			System.out.println(1);
			return;
		} x == 1 x 1 {
			System.out.println(1);
			return;
		} System.out.println(1) System.out.println System.out System System.out 1 return; int result = 0; result 0 for(int i = (int) Math.sqrt(x); i > 1; i--){
			int max = 0;
			int j = i;
			while(max <= x ){
				j *= i;
				if(j > x) break;
				if(max < j) max = j;
			}
			if(result < max) result = max;
		} int i = (int) Math.sqrt(x); int i = (int) Math.sqrt(x); i (int) Math.sqrt(x) Math.sqrt Math x i > 1 i 1 i-- i-- i {
			int max = 0;
			int j = i;
			while(max <= x ){
				j *= i;
				if(j > x) break;
				if(max < j) max = j;
			}
			if(result < max) result = max;
		} {
			int max = 0;
			int j = i;
			while(max <= x ){
				j *= i;
				if(j > x) break;
				if(max < j) max = j;
			}
			if(result < max) result = max;
		} int max = 0; max 0 int j = i; j i while(max <= x ){
				j *= i;
				if(j > x) break;
				if(max < j) max = j;
			} max <= x max x {
				j *= i;
				if(j > x) break;
				if(max < j) max = j;
			} j *= i j i if(j > x) break; j > x j x break; if(max < j) max = j; max < j max j max = j max j if(result < max) result = max; result < max result max result = max result max System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();

		if(x == 1){
			System.out.println(1);
			return;
		}

		int result = 0;
		for(int i = (int) Math.sqrt(x); i > 1; i--){
			int max = 0;
			int j = i;
			while(max <= x ){
				j *= i;
				if(j > x) break;
				if(max < j) max = j;
			}
			if(result < max) result = max;
		}
		System.out.println(result);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();

		if(x == 1){
			System.out.println(1);
			return;
		}

		int result = 0;
		for(int i = (int) Math.sqrt(x); i > 1; i--){
			int max = 0;
			int j = i;
			while(max <= x ){
				j *= i;
				if(j > x) break;
				if(max < j) max = j;
			}
			if(result < max) result = max;
		}
		System.out.println(result);
	}
} Main
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();

		if(x == 1){
			System.out.println(1);
			return;
		}

		int result = 0;
		for(int i = (int) Math.sqrt(x); i > 1; i--){
			int max = 0;
			int j = i;
			while(max <= x ){
				j *= i;
				if(j > x) break;
				if(max < j) max = j;
			}
			if(result < max) result = max;
		}
		System.out.println(result);
	}
}