
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int ans = 1;
		for(int i = 2; i < x; i++) {
			int j = i;
			if(x >= Math.pow(j, 2)) {
				while(j <= x) {
					j *= i;
				}
				j /= i;
				ans = Math.max(ans, j);
			}
		}
		System.out.println(ans);

	}

} 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 ans = 1;
		for(int i = 2; i < x; i++) {
			int j = i;
			if(x >= Math.pow(j, 2)) {
				while(j <= x) {
					j *= i;
				}
				j /= i;
				ans = Math.max(ans, j);
			}
		}
		System.out.println(ans);

	}

} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int ans = 1;
		for(int i = 2; i < x; i++) {
			int j = i;
			if(x >= Math.pow(j, 2)) {
				while(j <= x) {
					j *= i;
				}
				j /= i;
				ans = Math.max(ans, j);
			}
		}
		System.out.println(ans);

	} main {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int ans = 1;
		for(int i = 2; i < x; i++) {
			int j = i;
			if(x >= Math.pow(j, 2)) {
				while(j <= x) {
					j *= i;
				}
				j /= i;
				ans = Math.max(ans, j);
			}
		}
		System.out.println(ans);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int ans = 1; ans 1 for(int i = 2; i < x; i++) {
			int j = i;
			if(x >= Math.pow(j, 2)) {
				while(j <= x) {
					j *= i;
				}
				j /= i;
				ans = Math.max(ans, j);
			}
		} int i = 2; int i = 2; i 2 i < x i x i++ i++ i {
			int j = i;
			if(x >= Math.pow(j, 2)) {
				while(j <= x) {
					j *= i;
				}
				j /= i;
				ans = Math.max(ans, j);
			}
		} {
			int j = i;
			if(x >= Math.pow(j, 2)) {
				while(j <= x) {
					j *= i;
				}
				j /= i;
				ans = Math.max(ans, j);
			}
		} int j = i; j i if(x >= Math.pow(j, 2)) {
				while(j <= x) {
					j *= i;
				}
				j /= i;
				ans = Math.max(ans, j);
			} x >= Math.pow(j, 2) x Math.pow(j, 2) Math.pow Math j 2 {
				while(j <= x) {
					j *= i;
				}
				j /= i;
				ans = Math.max(ans, j);
			} while(j <= x) {
					j *= i;
				} j <= x j x {
					j *= i;
				} j *= i j i j /= i j i ans = Math.max(ans, j) ans Math.max(ans, j) Math.max Math ans j System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int ans = 1;
		for(int i = 2; i < x; i++) {
			int j = i;
			if(x >= Math.pow(j, 2)) {
				while(j <= x) {
					j *= i;
				}
				j /= i;
				ans = Math.max(ans, j);
			}
		}
		System.out.println(ans);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int ans = 1;
		for(int i = 2; i < x; i++) {
			int j = i;
			if(x >= Math.pow(j, 2)) {
				while(j <= x) {
					j *= i;
				}
				j /= i;
				ans = Math.max(ans, j);
			}
		}
		System.out.println(ans);

	}

} Main

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int ans = 1;
		for(int i = 2; i < x; i++) {
			int j = i;
			if(x >= Math.pow(j, 2)) {
				while(j <= x) {
					j *= i;
				}
				j /= i;
				ans = Math.max(ans, j);
			}
		}
		System.out.println(ans);

	}

}
