import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
        int a = 0, b, p, i, t;
		for(b = 1;b <= x;b++) {
			t = b;
			for(p = 2;p <= x;p++) {
				t *= b;
				if(t <=x && a < t) a = t;
			}
		}
		if(x == 1) a = 1;
		System.out.print(a);
	}
} import java.util.Scanner; Scanner java.util public class Main{
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
        int a = 0, b, p, i, t;
		for(b = 1;b <= x;b++) {
			t = b;
			for(p = 2;p <= x;p++) {
				t *= b;
				if(t <=x && a < t) a = t;
			}
		}
		if(x == 1) a = 1;
		System.out.print(a);
	}
} Main public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
        int a = 0, b, p, i, t;
		for(b = 1;b <= x;b++) {
			t = b;
			for(p = 2;p <= x;p++) {
				t *= b;
				if(t <=x && a < t) a = t;
			}
		}
		if(x == 1) a = 1;
		System.out.print(a);
	} main {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
        int a = 0, b, p, i, t;
		for(b = 1;b <= x;b++) {
			t = b;
			for(p = 2;p <= x;p++) {
				t *= b;
				if(t <=x && a < t) a = t;
			}
		}
		if(x == 1) a = 1;
		System.out.print(a);
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int x = stdIn.nextInt(); x stdIn.nextInt() stdIn.nextInt stdIn int a = 0 a 0 b b p p i i t; t for(b = 1;b <= x;b++) {
			t = b;
			for(p = 2;p <= x;p++) {
				t *= b;
				if(t <=x && a < t) a = t;
			}
		} b = 1; b = 1 b 1 b <= x b x b++ b++ b {
			t = b;
			for(p = 2;p <= x;p++) {
				t *= b;
				if(t <=x && a < t) a = t;
			}
		} {
			t = b;
			for(p = 2;p <= x;p++) {
				t *= b;
				if(t <=x && a < t) a = t;
			}
		} t = b t b for(p = 2;p <= x;p++) {
				t *= b;
				if(t <=x && a < t) a = t;
			} p = 2; p = 2 p 2 p <= x p x p++ p++ p {
				t *= b;
				if(t <=x && a < t) a = t;
			} {
				t *= b;
				if(t <=x && a < t) a = t;
			} t *= b t b if(t <=x && a < t) a = t; t <=x && a < t t <=x t x a < t a t a = t a t if(x == 1) a = 1; x == 1 x 1 a = 1 a 1 System.out.print(a) System.out.print System.out System System.out a String[] args args public class Main{
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
        int a = 0, b, p, i, t;
		for(b = 1;b <= x;b++) {
			t = b;
			for(p = 2;p <= x;p++) {
				t *= b;
				if(t <=x && a < t) a = t;
			}
		}
		if(x == 1) a = 1;
		System.out.print(a);
	}
} public class Main{
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
        int a = 0, b, p, i, t;
		for(b = 1;b <= x;b++) {
			t = b;
			for(p = 2;p <= x;p++) {
				t *= b;
				if(t <=x && a < t) a = t;
			}
		}
		if(x == 1) a = 1;
		System.out.print(a);
	}
} Main
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
        int a = 0, b, p, i, t;
		for(b = 1;b <= x;b++) {
			t = b;
			for(p = 2;p <= x;p++) {
				t *= b;
				if(t <=x && a < t) a = t;
			}
		}
		if(x == 1) a = 1;
		System.out.print(a);
	}
}
