import java.util.Scanner;

public class Main {

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

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

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