import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int X = Integer.parseInt(br.readLine());
		List<Integer> beki = new ArrayList<Integer>();
		beki.add(1);

		for(int i = 2;i<32;i++){
			int p = 2;
			int now = (int)Math.pow(i, p);
			while(now <= X){
				beki.add(now);
				p++;
				now = (int)Math.pow(i, p);

			}
		}

		beki.sort(null);
		System.out.println(beki.get(beki.size()-1));

	}


} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int X = Integer.parseInt(br.readLine());
		List<Integer> beki = new ArrayList<Integer>();
		beki.add(1);

		for(int i = 2;i<32;i++){
			int p = 2;
			int now = (int)Math.pow(i, p);
			while(now <= X){
				beki.add(now);
				p++;
				now = (int)Math.pow(i, p);

			}
		}

		beki.sort(null);
		System.out.println(beki.get(beki.size()-1));

	}


} Main public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int X = Integer.parseInt(br.readLine());
		List<Integer> beki = new ArrayList<Integer>();
		beki.add(1);

		for(int i = 2;i<32;i++){
			int p = 2;
			int now = (int)Math.pow(i, p);
			while(now <= X){
				beki.add(now);
				p++;
				now = (int)Math.pow(i, p);

			}
		}

		beki.sort(null);
		System.out.println(beki.get(beki.size()-1));

	} main {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int X = Integer.parseInt(br.readLine());
		List<Integer> beki = new ArrayList<Integer>();
		beki.add(1);

		for(int i = 2;i<32;i++){
			int p = 2;
			int now = (int)Math.pow(i, p);
			while(now <= X){
				beki.add(now);
				p++;
				now = (int)Math.pow(i, p);

			}
		}

		beki.sort(null);
		System.out.println(beki.get(beki.size()-1));

	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int X = Integer.parseInt(br.readLine()); X Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br List<Integer> beki = new ArrayList<Integer>(); beki new ArrayList<Integer>() beki.add(1) beki.add beki 1 for(int i = 2;i<32;i++){
			int p = 2;
			int now = (int)Math.pow(i, p);
			while(now <= X){
				beki.add(now);
				p++;
				now = (int)Math.pow(i, p);

			}
		} int i = 2; int i = 2; i 2 i<32 i 32 i++ i++ i {
			int p = 2;
			int now = (int)Math.pow(i, p);
			while(now <= X){
				beki.add(now);
				p++;
				now = (int)Math.pow(i, p);

			}
		} {
			int p = 2;
			int now = (int)Math.pow(i, p);
			while(now <= X){
				beki.add(now);
				p++;
				now = (int)Math.pow(i, p);

			}
		} int p = 2; p 2 int now = (int)Math.pow(i, p); now (int)Math.pow(i, p) Math.pow Math i p while(now <= X){
				beki.add(now);
				p++;
				now = (int)Math.pow(i, p);

			} now <= X now X {
				beki.add(now);
				p++;
				now = (int)Math.pow(i, p);

			} beki.add(now) beki.add beki now p++ p now = (int)Math.pow(i, p) now (int)Math.pow(i, p) Math.pow Math i p beki.sort(null) beki.sort beki null System.out.println(beki.get(beki.size()-1)) System.out.println System.out System System.out beki.get(beki.size()-1) beki.get beki beki.size()-1 beki.size() beki.size beki 1 String[] args args public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int X = Integer.parseInt(br.readLine());
		List<Integer> beki = new ArrayList<Integer>();
		beki.add(1);

		for(int i = 2;i<32;i++){
			int p = 2;
			int now = (int)Math.pow(i, p);
			while(now <= X){
				beki.add(now);
				p++;
				now = (int)Math.pow(i, p);

			}
		}

		beki.sort(null);
		System.out.println(beki.get(beki.size()-1));

	}


} public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int X = Integer.parseInt(br.readLine());
		List<Integer> beki = new ArrayList<Integer>();
		beki.add(1);

		for(int i = 2;i<32;i++){
			int p = 2;
			int now = (int)Math.pow(i, p);
			while(now <= X){
				beki.add(now);
				p++;
				now = (int)Math.pow(i, p);

			}
		}

		beki.sort(null);
		System.out.println(beki.get(beki.size()-1));

	}


} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int X = Integer.parseInt(br.readLine());
		List<Integer> beki = new ArrayList<Integer>();
		beki.add(1);

		for(int i = 2;i<32;i++){
			int p = 2;
			int now = (int)Math.pow(i, p);
			while(now <= X){
				beki.add(now);
				p++;
				now = (int)Math.pow(i, p);

			}
		}

		beki.sort(null);
		System.out.println(beki.get(beki.size()-1));

	}


}