
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int m = (int) Math.sqrt(n);
		int ans = 1;
		int max = 0;
		for (int i = 2; i <= m; i++) {
			for (int j = 2;; j++) {
				if (Math.pow(i, j) > n) break;
					max = (int) Math.pow(i, j);
			}
			ans = Math.max(ans, max);
		}
		
		System.out.println(ans);
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int m = (int) Math.sqrt(n);
		int ans = 1;
		int max = 0;
		for (int i = 2; i <= m; i++) {
			for (int j = 2;; j++) {
				if (Math.pow(i, j) > n) break;
					max = (int) Math.pow(i, j);
			}
			ans = Math.max(ans, max);
		}
		
		System.out.println(ans);
	}
} Main public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int m = (int) Math.sqrt(n);
		int ans = 1;
		int max = 0;
		for (int i = 2; i <= m; i++) {
			for (int j = 2;; j++) {
				if (Math.pow(i, j) > n) break;
					max = (int) Math.pow(i, j);
			}
			ans = Math.max(ans, max);
		}
		
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int m = (int) Math.sqrt(n);
		int ans = 1;
		int max = 0;
		for (int i = 2; i <= m; i++) {
			for (int j = 2;; j++) {
				if (Math.pow(i, j) > n) break;
					max = (int) Math.pow(i, j);
			}
			ans = Math.max(ans, max);
		}
		
		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 m = (int) Math.sqrt(n); m (int) Math.sqrt(n) Math.sqrt Math n int ans = 1; ans 1 int max = 0; max 0 for (int i = 2; i <= m; i++) {
			for (int j = 2;; j++) {
				if (Math.pow(i, j) > n) break;
					max = (int) Math.pow(i, j);
			}
			ans = Math.max(ans, max);
		} int i = 2; int i = 2; i 2 i <= m i m i++ i++ i {
			for (int j = 2;; j++) {
				if (Math.pow(i, j) > n) break;
					max = (int) Math.pow(i, j);
			}
			ans = Math.max(ans, max);
		} {
			for (int j = 2;; j++) {
				if (Math.pow(i, j) > n) break;
					max = (int) Math.pow(i, j);
			}
			ans = Math.max(ans, max);
		} for (int j = 2;; j++) {
				if (Math.pow(i, j) > n) break;
					max = (int) Math.pow(i, j);
			} int j = 2; int j = 2; j 2 j++ j++ j {
				if (Math.pow(i, j) > n) break;
					max = (int) Math.pow(i, j);
			} {
				if (Math.pow(i, j) > n) break;
					max = (int) Math.pow(i, j);
			} if (Math.pow(i, j) > n) break; Math.pow(i, j) > n Math.pow(i, j) Math.pow Math i j n break; max = (int) Math.pow(i, j) max (int) Math.pow(i, j) Math.pow Math i j ans = Math.max(ans, max) ans Math.max(ans, max) Math.max Math ans max System.out.println(ans) System.out.println System.out System System.out ans String args[] args

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int m = (int) Math.sqrt(n);
		int ans = 1;
		int max = 0;
		for (int i = 2; i <= m; i++) {
			for (int j = 2;; j++) {
				if (Math.pow(i, j) > n) break;
					max = (int) Math.pow(i, j);
			}
			ans = Math.max(ans, max);
		}
		
		System.out.println(ans);
	}
}