import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
	int b = 1;
	int p = 2;
	double max = 0;
	double result;
	Scanner scanner = new Scanner(System.in);
	int x = scanner.nextInt();
	while (b < 1000) {
	    while (p < 1000) {
		result = Math.pow(b, p);
		if (result > x ) break;
		if (result >= max) max = result;
		p++;
	    }
	    p = 2;
	    b++;
	}
	System.out.println((int)max);
    }
    
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String args[]) {
	int b = 1;
	int p = 2;
	double max = 0;
	double result;
	Scanner scanner = new Scanner(System.in);
	int x = scanner.nextInt();
	while (b < 1000) {
	    while (p < 1000) {
		result = Math.pow(b, p);
		if (result > x ) break;
		if (result >= max) max = result;
		p++;
	    }
	    p = 2;
	    b++;
	}
	System.out.println((int)max);
    }
    
} Main public static void main(String args[]) {
	int b = 1;
	int p = 2;
	double max = 0;
	double result;
	Scanner scanner = new Scanner(System.in);
	int x = scanner.nextInt();
	while (b < 1000) {
	    while (p < 1000) {
		result = Math.pow(b, p);
		if (result > x ) break;
		if (result >= max) max = result;
		p++;
	    }
	    p = 2;
	    b++;
	}
	System.out.println((int)max);
    } main {
	int b = 1;
	int p = 2;
	double max = 0;
	double result;
	Scanner scanner = new Scanner(System.in);
	int x = scanner.nextInt();
	while (b < 1000) {
	    while (p < 1000) {
		result = Math.pow(b, p);
		if (result > x ) break;
		if (result >= max) max = result;
		p++;
	    }
	    p = 2;
	    b++;
	}
	System.out.println((int)max);
    } int b = 1; b 1 int p = 2; p 2 double max = 0; max 0 double result; result Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int x = scanner.nextInt(); x scanner.nextInt() scanner.nextInt scanner while (b < 1000) {
	    while (p < 1000) {
		result = Math.pow(b, p);
		if (result > x ) break;
		if (result >= max) max = result;
		p++;
	    }
	    p = 2;
	    b++;
	} b < 1000 b 1000 {
	    while (p < 1000) {
		result = Math.pow(b, p);
		if (result > x ) break;
		if (result >= max) max = result;
		p++;
	    }
	    p = 2;
	    b++;
	} while (p < 1000) {
		result = Math.pow(b, p);
		if (result > x ) break;
		if (result >= max) max = result;
		p++;
	    } p < 1000 p 1000 {
		result = Math.pow(b, p);
		if (result > x ) break;
		if (result >= max) max = result;
		p++;
	    } result = Math.pow(b, p) result Math.pow(b, p) Math.pow Math b p if (result > x ) break; result > x result x break; if (result >= max) max = result; result >= max result max max = result max result p++ p p = 2 p 2 b++ b System.out.println((int)max) System.out.println System.out System System.out (int)max String args[] args public class Main {
    public static void main(String args[]) {
	int b = 1;
	int p = 2;
	double max = 0;
	double result;
	Scanner scanner = new Scanner(System.in);
	int x = scanner.nextInt();
	while (b < 1000) {
	    while (p < 1000) {
		result = Math.pow(b, p);
		if (result > x ) break;
		if (result >= max) max = result;
		p++;
	    }
	    p = 2;
	    b++;
	}
	System.out.println((int)max);
    }
    
} public class Main {
    public static void main(String args[]) {
	int b = 1;
	int p = 2;
	double max = 0;
	double result;
	Scanner scanner = new Scanner(System.in);
	int x = scanner.nextInt();
	while (b < 1000) {
	    while (p < 1000) {
		result = Math.pow(b, p);
		if (result > x ) break;
		if (result >= max) max = result;
		p++;
	    }
	    p = 2;
	    b++;
	}
	System.out.println((int)max);
    }
    
} Main
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
	int b = 1;
	int p = 2;
	double max = 0;
	double result;
	Scanner scanner = new Scanner(System.in);
	int x = scanner.nextInt();
	while (b < 1000) {
	    while (p < 1000) {
		result = Math.pow(b, p);
		if (result > x ) break;
		if (result >= max) max = result;
		p++;
	    }
	    p = 2;
	    b++;
	}
	System.out.println((int)max);
    }
    
}
