

import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();

		int result = 1;
		for(int i = 2; i <= x - 1; i++){
			int p = 2;

			while(Math.pow(i, p) <= x){
				result = (int)Math.max(result, Math.pow(i, p));
				p++;
			}
		}

		System.out.println(result);
	}
} import java.io.IOException; IOException java.io import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();

		int result = 1;
		for(int i = 2; i <= x - 1; i++){
			int p = 2;

			while(Math.pow(i, p) <= x){
				result = (int)Math.max(result, Math.pow(i, p));
				p++;
			}
		}

		System.out.println(result);
	}
} Main public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();

		int result = 1;
		for(int i = 2; i <= x - 1; i++){
			int p = 2;

			while(Math.pow(i, p) <= x){
				result = (int)Math.max(result, Math.pow(i, p));
				p++;
			}
		}

		System.out.println(result);
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();

		int result = 1;
		for(int i = 2; i <= x - 1; i++){
			int p = 2;

			while(Math.pow(i, p) <= x){
				result = (int)Math.max(result, Math.pow(i, p));
				p++;
			}
		}

		System.out.println(result);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int result = 1; result 1 for(int i = 2; i <= x - 1; i++){
			int p = 2;

			while(Math.pow(i, p) <= x){
				result = (int)Math.max(result, Math.pow(i, p));
				p++;
			}
		} int i = 2; int i = 2; i 2 i <= x - 1 i x - 1 x 1 i++ i++ i {
			int p = 2;

			while(Math.pow(i, p) <= x){
				result = (int)Math.max(result, Math.pow(i, p));
				p++;
			}
		} {
			int p = 2;

			while(Math.pow(i, p) <= x){
				result = (int)Math.max(result, Math.pow(i, p));
				p++;
			}
		} int p = 2; p 2 while(Math.pow(i, p) <= x){
				result = (int)Math.max(result, Math.pow(i, p));
				p++;
			} Math.pow(i, p) <= x Math.pow(i, p) Math.pow Math i p x {
				result = (int)Math.max(result, Math.pow(i, p));
				p++;
			} result = (int)Math.max(result, Math.pow(i, p)) result (int)Math.max(result, Math.pow(i, p)) Math.max Math result Math.pow(i, p) Math.pow Math i p p++ p System.out.println(result) System.out.println System.out System System.out result String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();

		int result = 1;
		for(int i = 2; i <= x - 1; i++){
			int p = 2;

			while(Math.pow(i, p) <= x){
				result = (int)Math.max(result, Math.pow(i, p));
				p++;
			}
		}

		System.out.println(result);
	}
} public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();

		int result = 1;
		for(int i = 2; i <= x - 1; i++){
			int p = 2;

			while(Math.pow(i, p) <= x){
				result = (int)Math.max(result, Math.pow(i, p));
				p++;
			}
		}

		System.out.println(result);
	}
} Main


import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();

		int result = 1;
		for(int i = 2; i <= x - 1; i++){
			int p = 2;

			while(Math.pow(i, p) <= x){
				result = (int)Math.max(result, Math.pow(i, p));
				p++;
			}
		}

		System.out.println(result);
	}
}
