import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();
		int max = 0;
		for (int i = 1; i <= 1000; ++i) {
			if (i != 1) {
				for (int j = 2; j <= 10; ++j) {
					int tmp = (int) Math.pow(i, j);
					if (tmp <= x)
						max = Math.max(max, tmp);
					else
						break;
				}
			} else {
				if (i <= x)
					max = Math.max(max, i);
			}
		}
		System.out.println(max);
	}

} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();
		int max = 0;
		for (int i = 1; i <= 1000; ++i) {
			if (i != 1) {
				for (int j = 2; j <= 10; ++j) {
					int tmp = (int) Math.pow(i, j);
					if (tmp <= x)
						max = Math.max(max, tmp);
					else
						break;
				}
			} else {
				if (i <= x)
					max = Math.max(max, i);
			}
		}
		System.out.println(max);
	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();
		int max = 0;
		for (int i = 1; i <= 1000; ++i) {
			if (i != 1) {
				for (int j = 2; j <= 10; ++j) {
					int tmp = (int) Math.pow(i, j);
					if (tmp <= x)
						max = Math.max(max, tmp);
					else
						break;
				}
			} else {
				if (i <= x)
					max = Math.max(max, i);
			}
		}
		System.out.println(max);
	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();
		int max = 0;
		for (int i = 1; i <= 1000; ++i) {
			if (i != 1) {
				for (int j = 2; j <= 10; ++j) {
					int tmp = (int) Math.pow(i, j);
					if (tmp <= x)
						max = Math.max(max, tmp);
					else
						break;
				}
			} else {
				if (i <= x)
					max = Math.max(max, i);
			}
		}
		System.out.println(max);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc sc.close() sc.close sc int max = 0; max 0 for (int i = 1; i <= 1000; ++i) {
			if (i != 1) {
				for (int j = 2; j <= 10; ++j) {
					int tmp = (int) Math.pow(i, j);
					if (tmp <= x)
						max = Math.max(max, tmp);
					else
						break;
				}
			} else {
				if (i <= x)
					max = Math.max(max, i);
			}
		} int i = 1; int i = 1; i 1 i <= 1000 i 1000 ++i ++i i {
			if (i != 1) {
				for (int j = 2; j <= 10; ++j) {
					int tmp = (int) Math.pow(i, j);
					if (tmp <= x)
						max = Math.max(max, tmp);
					else
						break;
				}
			} else {
				if (i <= x)
					max = Math.max(max, i);
			}
		} {
			if (i != 1) {
				for (int j = 2; j <= 10; ++j) {
					int tmp = (int) Math.pow(i, j);
					if (tmp <= x)
						max = Math.max(max, tmp);
					else
						break;
				}
			} else {
				if (i <= x)
					max = Math.max(max, i);
			}
		} if (i != 1) {
				for (int j = 2; j <= 10; ++j) {
					int tmp = (int) Math.pow(i, j);
					if (tmp <= x)
						max = Math.max(max, tmp);
					else
						break;
				}
			} else {
				if (i <= x)
					max = Math.max(max, i);
			} i != 1 i 1 {
				for (int j = 2; j <= 10; ++j) {
					int tmp = (int) Math.pow(i, j);
					if (tmp <= x)
						max = Math.max(max, tmp);
					else
						break;
				}
			} for (int j = 2; j <= 10; ++j) {
					int tmp = (int) Math.pow(i, j);
					if (tmp <= x)
						max = Math.max(max, tmp);
					else
						break;
				} int j = 2; int j = 2; j 2 j <= 10 j 10 ++j ++j j {
					int tmp = (int) Math.pow(i, j);
					if (tmp <= x)
						max = Math.max(max, tmp);
					else
						break;
				} {
					int tmp = (int) Math.pow(i, j);
					if (tmp <= x)
						max = Math.max(max, tmp);
					else
						break;
				} int tmp = (int) Math.pow(i, j); tmp (int) Math.pow(i, j) Math.pow Math i j if (tmp <= x)
						max = Math.max(max, tmp);
					else
						break; tmp <= x tmp x max = Math.max(max, tmp) max Math.max(max, tmp) Math.max Math max tmp break; {
				if (i <= x)
					max = Math.max(max, i);
			} if (i <= x)
					max = Math.max(max, i); i <= x i x max = Math.max(max, i) max Math.max(max, i) Math.max Math max i System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();
		int max = 0;
		for (int i = 1; i <= 1000; ++i) {
			if (i != 1) {
				for (int j = 2; j <= 10; ++j) {
					int tmp = (int) Math.pow(i, j);
					if (tmp <= x)
						max = Math.max(max, tmp);
					else
						break;
				}
			} else {
				if (i <= x)
					max = Math.max(max, i);
			}
		}
		System.out.println(max);
	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();
		int max = 0;
		for (int i = 1; i <= 1000; ++i) {
			if (i != 1) {
				for (int j = 2; j <= 10; ++j) {
					int tmp = (int) Math.pow(i, j);
					if (tmp <= x)
						max = Math.max(max, tmp);
					else
						break;
				}
			} else {
				if (i <= x)
					max = Math.max(max, i);
			}
		}
		System.out.println(max);
	}

} Main
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();
		int max = 0;
		for (int i = 1; i <= 1000; ++i) {
			if (i != 1) {
				for (int j = 2; j <= 10; ++j) {
					int tmp = (int) Math.pow(i, j);
					if (tmp <= x)
						max = Math.max(max, tmp);
					else
						break;
				}
			} else {
				if (i <= x)
					max = Math.max(max, i);
			}
		}
		System.out.println(max);
	}

}
