import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int max = 0;

		for (int i = 1; i <= Math.sqrt(x); i++) {
			int tmp = 1;
			for (int j = 2; j < 10; j++) {
				if (tmp * i > x) {
					break;
				}
				tmp *= i;
				if (max < tmp) {
					max = tmp;
				}
			}

		}
		System.out.print(max);

	}
} import java.util.Arrays; Arrays java.util 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 max = 0;

		for (int i = 1; i <= Math.sqrt(x); i++) {
			int tmp = 1;
			for (int j = 2; j < 10; j++) {
				if (tmp * i > x) {
					break;
				}
				tmp *= i;
				if (max < tmp) {
					max = tmp;
				}
			}

		}
		System.out.print(max);

	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int max = 0;

		for (int i = 1; i <= Math.sqrt(x); i++) {
			int tmp = 1;
			for (int j = 2; j < 10; j++) {
				if (tmp * i > x) {
					break;
				}
				tmp *= i;
				if (max < tmp) {
					max = tmp;
				}
			}

		}
		System.out.print(max);

	} main {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int max = 0;

		for (int i = 1; i <= Math.sqrt(x); i++) {
			int tmp = 1;
			for (int j = 2; j < 10; j++) {
				if (tmp * i > x) {
					break;
				}
				tmp *= i;
				if (max < tmp) {
					max = tmp;
				}
			}

		}
		System.out.print(max);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int max = 0; max 0 for (int i = 1; i <= Math.sqrt(x); i++) {
			int tmp = 1;
			for (int j = 2; j < 10; j++) {
				if (tmp * i > x) {
					break;
				}
				tmp *= i;
				if (max < tmp) {
					max = tmp;
				}
			}

		} int i = 1; int i = 1; i 1 i <= Math.sqrt(x) i Math.sqrt(x) Math.sqrt Math x i++ i++ i {
			int tmp = 1;
			for (int j = 2; j < 10; j++) {
				if (tmp * i > x) {
					break;
				}
				tmp *= i;
				if (max < tmp) {
					max = tmp;
				}
			}

		} {
			int tmp = 1;
			for (int j = 2; j < 10; j++) {
				if (tmp * i > x) {
					break;
				}
				tmp *= i;
				if (max < tmp) {
					max = tmp;
				}
			}

		} int tmp = 1; tmp 1 for (int j = 2; j < 10; j++) {
				if (tmp * i > x) {
					break;
				}
				tmp *= i;
				if (max < tmp) {
					max = tmp;
				}
			} int j = 2; int j = 2; j 2 j < 10 j 10 j++ j++ j {
				if (tmp * i > x) {
					break;
				}
				tmp *= i;
				if (max < tmp) {
					max = tmp;
				}
			} {
				if (tmp * i > x) {
					break;
				}
				tmp *= i;
				if (max < tmp) {
					max = tmp;
				}
			} if (tmp * i > x) {
					break;
				} tmp * i > x tmp * i tmp i x {
					break;
				} break; tmp *= i tmp i if (max < tmp) {
					max = tmp;
				} max < tmp max tmp {
					max = tmp;
				} max = tmp max tmp System.out.print(max) System.out.print 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();
		int max = 0;

		for (int i = 1; i <= Math.sqrt(x); i++) {
			int tmp = 1;
			for (int j = 2; j < 10; j++) {
				if (tmp * i > x) {
					break;
				}
				tmp *= i;
				if (max < tmp) {
					max = tmp;
				}
			}

		}
		System.out.print(max);

	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int max = 0;

		for (int i = 1; i <= Math.sqrt(x); i++) {
			int tmp = 1;
			for (int j = 2; j < 10; j++) {
				if (tmp * i > x) {
					break;
				}
				tmp *= i;
				if (max < tmp) {
					max = tmp;
				}
			}

		}
		System.out.print(max);

	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int max = 0;

		for (int i = 1; i <= Math.sqrt(x); i++) {
			int tmp = 1;
			for (int j = 2; j < 10; j++) {
				if (tmp * i > x) {
					break;
				}
				tmp *= i;
				if (max < tmp) {
					max = tmp;
				}
			}

		}
		System.out.print(max);

	}
}
