import java.util.Scanner;

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

		int X = sc.nextInt();
		int ans = 0;
		
		for (int i = 1; i < 33; i++){
			
			int tmp = i;
			
			for (int j = 0; j < 9; j++){
				tmp *= i;
				
				if (ans < tmp && tmp <= X){
					ans = tmp;
			}
			
			}

		}
		
		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();
		int ans = 0;
		
		for (int i = 1; i < 33; i++){
			
			int tmp = i;
			
			for (int j = 0; j < 9; j++){
				tmp *= i;
				
				if (ans < tmp && tmp <= X){
					ans = tmp;
			}
			
			}

		}
		
		System.out.println(ans);

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

		int X = sc.nextInt();
		int ans = 0;
		
		for (int i = 1; i < 33; i++){
			
			int tmp = i;
			
			for (int j = 0; j < 9; j++){
				tmp *= i;
				
				if (ans < tmp && tmp <= X){
					ans = tmp;
			}
			
			}

		}
		
		System.out.println(ans);

	} main {
		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int ans = 0;
		
		for (int i = 1; i < 33; i++){
			
			int tmp = i;
			
			for (int j = 0; j < 9; j++){
				tmp *= i;
				
				if (ans < tmp && tmp <= X){
					ans = tmp;
			}
			
			}

		}
		
		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 int ans = 0; ans 0 for (int i = 1; i < 33; i++){
			
			int tmp = i;
			
			for (int j = 0; j < 9; j++){
				tmp *= i;
				
				if (ans < tmp && tmp <= X){
					ans = tmp;
			}
			
			}

		} int i = 1; int i = 1; i 1 i < 33 i 33 i++ i++ i {
			
			int tmp = i;
			
			for (int j = 0; j < 9; j++){
				tmp *= i;
				
				if (ans < tmp && tmp <= X){
					ans = tmp;
			}
			
			}

		} {
			
			int tmp = i;
			
			for (int j = 0; j < 9; j++){
				tmp *= i;
				
				if (ans < tmp && tmp <= X){
					ans = tmp;
			}
			
			}

		} int tmp = i; tmp i for (int j = 0; j < 9; j++){
				tmp *= i;
				
				if (ans < tmp && tmp <= X){
					ans = tmp;
			}
			
			} int j = 0; int j = 0; j 0 j < 9 j 9 j++ j++ j {
				tmp *= i;
				
				if (ans < tmp && tmp <= X){
					ans = tmp;
			}
			
			} {
				tmp *= i;
				
				if (ans < tmp && tmp <= X){
					ans = tmp;
			}
			
			} tmp *= i tmp i if (ans < tmp && tmp <= X){
					ans = tmp;
			} ans < tmp && tmp <= X ans < tmp ans tmp tmp <= X tmp X {
					ans = tmp;
			} ans = tmp ans tmp 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();
		int ans = 0;
		
		for (int i = 1; i < 33; i++){
			
			int tmp = i;
			
			for (int j = 0; j < 9; j++){
				tmp *= i;
				
				if (ans < tmp && tmp <= X){
					ans = tmp;
			}
			
			}

		}
		
		System.out.println(ans);

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

		int X = sc.nextInt();
		int ans = 0;
		
		for (int i = 1; i < 33; i++){
			
			int tmp = i;
			
			for (int j = 0; j < 9; j++){
				tmp *= i;
				
				if (ans < tmp && tmp <= X){
					ans = tmp;
			}
			
			}

		}
		
		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();
		int ans = 0;
		
		for (int i = 1; i < 33; i++){
			
			int tmp = i;
			
			for (int j = 0; j < 9; j++){
				tmp *= i;
				
				if (ans < tmp && tmp <= X){
					ans = tmp;
			}
			
			}

		}
		
		System.out.println(ans);

	}
}