
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int ans = 1;
		
		for (int i = 2; i * i <= n; i++) {
			for (int j = i * i; j <= n; 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 n = sc.nextInt();
		
		int ans = 1;
		
		for (int i = 2; i * i <= n; i++) {
			for (int j = i * i; j <= n; 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 n = sc.nextInt();
		
		int ans = 1;
		
		for (int i = 2; i * i <= n; i++) {
			for (int j = i * i; j <= n; j *= i) {
				ans = Math.max(ans, j);
			}
		}
		
		System.out.println(ans);
		
	} main {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int ans = 1;
		
		for (int i = 2; i * i <= n; i++) {
			for (int j = i * i; j <= n; j *= i) {
				ans = Math.max(ans, j);
			}
		}
		
		System.out.println(ans);
		
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int ans = 1; ans 1 for (int i = 2; i * i <= n; i++) {
			for (int j = i * i; j <= n; j *= i) {
				ans = Math.max(ans, j);
			}
		} int i = 2; int i = 2; i 2 i * i <= n i * i i i n i++ i++ i {
			for (int j = i * i; j <= n; j *= i) {
				ans = Math.max(ans, j);
			}
		} {
			for (int j = i * i; j <= n; j *= i) {
				ans = Math.max(ans, j);
			}
		} for (int j = i * i; j <= n; j *= i) {
				ans = Math.max(ans, j);
			} int j = i * i; int j = i * i; j i * i i i j <= n j n j *= i j *= i j i {
				ans = Math.max(ans, j);
			} {
				ans = Math.max(ans, j);
			} 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 n = sc.nextInt();
		
		int ans = 1;
		
		for (int i = 2; i * i <= n; i++) {
			for (int j = i * i; j <= n; 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 n = sc.nextInt();
		
		int ans = 1;
		
		for (int i = 2; i * i <= n; i++) {
			for (int j = i * i; j <= n; 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 n = sc.nextInt();
		
		int ans = 1;
		
		for (int i = 2; i * i <= n; i++) {
			for (int j = i * i; j <= n; j *= i) {
				ans = Math.max(ans, j);
			}
		}
		
		System.out.println(ans);
		
	}
	
}