import java.util.*;
import static java.lang.Math.*;

public class Main {
	
	public static void main(String... args) {
		System.out.println(calcExpMax(scanInt()));
	}
	
	private static final int MAX = (int) sqrt(1000d) + 1;
	
	private static int calcExpMax(int X) {
		int max = 1;
		for (int i = 2; i < MAX; ++i) {
			int pow = i;
			for (int j = 2; j < 9; ++j) {
				pow *= i;
				if (X < pow) {
					break;
				}
				if (max < pow) {
					max = pow;
				}
			}
		}
		return max;
	}

	
	private static final Scanner SC = new Scanner(System.in);

	private static int scanInt() {
		return SC.nextInt();
	}

	private static  String scanString() {
		return SC.next();
	}
}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz