import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int max = 1;
      	for(int i=2; i*i<=n; i++){
          int num = i;
          while (num <= n) {
				num *= i;
			}
			num /= i;
			max = Math.max(max, num);
        }
      	System.out.println(max);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int max = 1;
      	for(int i=2; i*i<=n; i++){
          int num = i;
          while (num <= n) {
				num *= i;
			}
			num /= i;
			max = Math.max(max, num);
        }
      	System.out.println(max);
	}
} Main public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int max = 1;
      	for(int i=2; i*i<=n; i++){
          int num = i;
          while (num <= n) {
				num *= i;
			}
			num /= i;
			max = Math.max(max, num);
        }
      	System.out.println(max);
	} main {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int max = 1;
      	for(int i=2; i*i<=n; i++){
          int num = i;
          while (num <= n) {
				num *= i;
			}
			num /= i;
			max = Math.max(max, num);
        }
      	System.out.println(max);
	} Scanner scn = new Scanner(System.in); scn new Scanner(System.in) int n = scn.nextInt(); n scn.nextInt() scn.nextInt scn int max = 1; max 1 for(int i=2; i*i<=n; i++){
          int num = i;
          while (num <= n) {
				num *= i;
			}
			num /= i;
			max = Math.max(max, num);
        } int i=2; int i=2; i 2 i*i<=n i*i i i n i++ i++ i {
          int num = i;
          while (num <= n) {
				num *= i;
			}
			num /= i;
			max = Math.max(max, num);
        } {
          int num = i;
          while (num <= n) {
				num *= i;
			}
			num /= i;
			max = Math.max(max, num);
        } int num = i; num i while (num <= n) {
				num *= i;
			} num <= n num n {
				num *= i;
			} num *= i num i num /= i num i max = Math.max(max, num) max Math.max(max, num) Math.max Math max num 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) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int max = 1;
      	for(int i=2; i*i<=n; i++){
          int num = i;
          while (num <= n) {
				num *= i;
			}
			num /= i;
			max = Math.max(max, num);
        }
      	System.out.println(max);
	}
} public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int max = 1;
      	for(int i=2; i*i<=n; i++){
          int num = i;
          while (num <= n) {
				num *= i;
			}
			num /= i;
			max = Math.max(max, num);
        }
      	System.out.println(max);
	}
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int max = 1;
      	for(int i=2; i*i<=n; i++){
          int num = i;
          while (num <= n) {
				num *= i;
			}
			num /= i;
			max = Math.max(max, num);
        }
      	System.out.println(max);
	}
}
