
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		long max = 1;
		for (int i = 1; i <= Math.sqrt(X); i++) {
			for (int j = 2; j <= Math.sqrt(X); j++) {
				long let = (long)Math.pow(i, j);
				if (let <= X && let > max) {
					max = let;
				}
			}
		}
		System.out.println(max);
		}

} 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();
		long max = 1;
		for (int i = 1; i <= Math.sqrt(X); i++) {
			for (int j = 2; j <= Math.sqrt(X); j++) {
				long let = (long)Math.pow(i, j);
				if (let <= X && let > max) {
					max = let;
				}
			}
		}
		System.out.println(max);
		}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		long max = 1;
		for (int i = 1; i <= Math.sqrt(X); i++) {
			for (int j = 2; j <= Math.sqrt(X); j++) {
				long let = (long)Math.pow(i, j);
				if (let <= X && let > max) {
					max = let;
				}
			}
		}
		System.out.println(max);
		} main {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		long max = 1;
		for (int i = 1; i <= Math.sqrt(X); i++) {
			for (int j = 2; j <= Math.sqrt(X); j++) {
				long let = (long)Math.pow(i, j);
				if (let <= X && let > max) {
					max = let;
				}
			}
		}
		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 long max = 1; max 1 for (int i = 1; i <= Math.sqrt(X); i++) {
			for (int j = 2; j <= Math.sqrt(X); j++) {
				long let = (long)Math.pow(i, j);
				if (let <= X && let > max) {
					max = let;
				}
			}
		} int i = 1; int i = 1; i 1 i <= Math.sqrt(X) i Math.sqrt(X) Math.sqrt Math X i++ i++ i {
			for (int j = 2; j <= Math.sqrt(X); j++) {
				long let = (long)Math.pow(i, j);
				if (let <= X && let > max) {
					max = let;
				}
			}
		} {
			for (int j = 2; j <= Math.sqrt(X); j++) {
				long let = (long)Math.pow(i, j);
				if (let <= X && let > max) {
					max = let;
				}
			}
		} for (int j = 2; j <= Math.sqrt(X); j++) {
				long let = (long)Math.pow(i, j);
				if (let <= X && let > max) {
					max = let;
				}
			} int j = 2; int j = 2; j 2 j <= Math.sqrt(X) j Math.sqrt(X) Math.sqrt Math X j++ j++ j {
				long let = (long)Math.pow(i, j);
				if (let <= X && let > max) {
					max = let;
				}
			} {
				long let = (long)Math.pow(i, j);
				if (let <= X && let > max) {
					max = let;
				}
			} long let = (long)Math.pow(i, j); let (long)Math.pow(i, j) Math.pow Math i j if (let <= X && let > max) {
					max = let;
				} let <= X && let > max let <= X let X let > max let max {
					max = let;
				} max = let max let 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();
		long max = 1;
		for (int i = 1; i <= Math.sqrt(X); i++) {
			for (int j = 2; j <= Math.sqrt(X); j++) {
				long let = (long)Math.pow(i, j);
				if (let <= X && let > max) {
					max = let;
				}
			}
		}
		System.out.println(max);
		}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		long max = 1;
		for (int i = 1; i <= Math.sqrt(X); i++) {
			for (int j = 2; j <= Math.sqrt(X); j++) {
				long let = (long)Math.pow(i, j);
				if (let <= X && let > max) {
					max = let;
				}
			}
		}
		System.out.println(max);
		}

} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		long max = 1;
		for (int i = 1; i <= Math.sqrt(X); i++) {
			for (int j = 2; j <= Math.sqrt(X); j++) {
				long let = (long)Math.pow(i, j);
				if (let <= X && let > max) {
					max = let;
				}
			}
		}
		System.out.println(max);
		}

}
