/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//, b = sc.nextInt(), c=  sc.nextInt(), d = sc.nextInt();
		int sqrt = (int)Math.sqrt(a);
		List<Integer> list = new ArrayList<>();
		if(a<=3){
			System.out.println(1);return;	
		}
		for(int i=2;i<=sqrt;i++){
			for(int ii=2;;ii++){
				if(Math.pow(i,ii)<a){
					list.add((int)Math.pow(i,ii));
				} else if(Math.pow(i,ii)==a){
					list.add((int)Math.pow(i,ii));break;
				} else break;	
			}
		}
		Collections.sort(list);
		System.out.println(list.get(list.size()-1));
	}
} import java.util.*; util.* java import java.lang.*; lang.* java import java.io.*; io.* java public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//, b = sc.nextInt(), c=  sc.nextInt(), d = sc.nextInt();
		int sqrt = (int)Math.sqrt(a);
		List<Integer> list = new ArrayList<>();
		if(a<=3){
			System.out.println(1);return;	
		}
		for(int i=2;i<=sqrt;i++){
			for(int ii=2;;ii++){
				if(Math.pow(i,ii)<a){
					list.add((int)Math.pow(i,ii));
				} else if(Math.pow(i,ii)==a){
					list.add((int)Math.pow(i,ii));break;
				} else break;	
			}
		}
		Collections.sort(list);
		System.out.println(list.get(list.size()-1));
	}
} Main public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//, b = sc.nextInt(), c=  sc.nextInt(), d = sc.nextInt();
		int sqrt = (int)Math.sqrt(a);
		List<Integer> list = new ArrayList<>();
		if(a<=3){
			System.out.println(1);return;	
		}
		for(int i=2;i<=sqrt;i++){
			for(int ii=2;;ii++){
				if(Math.pow(i,ii)<a){
					list.add((int)Math.pow(i,ii));
				} else if(Math.pow(i,ii)==a){
					list.add((int)Math.pow(i,ii));break;
				} else break;	
			}
		}
		Collections.sort(list);
		System.out.println(list.get(list.size()-1));
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//, b = sc.nextInt(), c=  sc.nextInt(), d = sc.nextInt();
		int sqrt = (int)Math.sqrt(a);
		List<Integer> list = new ArrayList<>();
		if(a<=3){
			System.out.println(1);return;	
		}
		for(int i=2;i<=sqrt;i++){
			for(int ii=2;;ii++){
				if(Math.pow(i,ii)<a){
					list.add((int)Math.pow(i,ii));
				} else if(Math.pow(i,ii)==a){
					list.add((int)Math.pow(i,ii));break;
				} else break;	
			}
		}
		Collections.sort(list);
		System.out.println(list.get(list.size()-1));
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int sqrt = (int)Math.sqrt(a); sqrt (int)Math.sqrt(a) Math.sqrt Math a List<Integer> list = new ArrayList<>(); list new ArrayList<>() if(a<=3){
			System.out.println(1);return;	
		} a<=3 a 3 {
			System.out.println(1);return;	
		} System.out.println(1) System.out.println System.out System System.out 1 return; for(int i=2;i<=sqrt;i++){
			for(int ii=2;;ii++){
				if(Math.pow(i,ii)<a){
					list.add((int)Math.pow(i,ii));
				} else if(Math.pow(i,ii)==a){
					list.add((int)Math.pow(i,ii));break;
				} else break;	
			}
		} int i=2; int i=2; i 2 i<=sqrt i sqrt i++ i++ i {
			for(int ii=2;;ii++){
				if(Math.pow(i,ii)<a){
					list.add((int)Math.pow(i,ii));
				} else if(Math.pow(i,ii)==a){
					list.add((int)Math.pow(i,ii));break;
				} else break;	
			}
		} {
			for(int ii=2;;ii++){
				if(Math.pow(i,ii)<a){
					list.add((int)Math.pow(i,ii));
				} else if(Math.pow(i,ii)==a){
					list.add((int)Math.pow(i,ii));break;
				} else break;	
			}
		} for(int ii=2;;ii++){
				if(Math.pow(i,ii)<a){
					list.add((int)Math.pow(i,ii));
				} else if(Math.pow(i,ii)==a){
					list.add((int)Math.pow(i,ii));break;
				} else break;	
			} int ii=2; int ii=2; ii 2 ii++ ii++ ii {
				if(Math.pow(i,ii)<a){
					list.add((int)Math.pow(i,ii));
				} else if(Math.pow(i,ii)==a){
					list.add((int)Math.pow(i,ii));break;
				} else break;	
			} {
				if(Math.pow(i,ii)<a){
					list.add((int)Math.pow(i,ii));
				} else if(Math.pow(i,ii)==a){
					list.add((int)Math.pow(i,ii));break;
				} else break;	
			} if(Math.pow(i,ii)<a){
					list.add((int)Math.pow(i,ii));
				} else if(Math.pow(i,ii)==a){
					list.add((int)Math.pow(i,ii));break;
				} else break; Math.pow(i,ii)<a Math.pow(i,ii) Math.pow Math i ii a {
					list.add((int)Math.pow(i,ii));
				} list.add((int)Math.pow(i,ii)) list.add list (int)Math.pow(i,ii) Math.pow Math i ii if(Math.pow(i,ii)==a){
					list.add((int)Math.pow(i,ii));break;
				} else break; Math.pow(i,ii)==a Math.pow(i,ii) Math.pow Math i ii a {
					list.add((int)Math.pow(i,ii));break;
				} list.add((int)Math.pow(i,ii)) list.add list (int)Math.pow(i,ii) Math.pow Math i ii break; break; Collections.sort(list) Collections.sort Collections list System.out.println(list.get(list.size()-1)) System.out.println System.out System System.out list.get(list.size()-1) list.get list list.size()-1 list.size() list.size list 1 String[] args args public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//, b = sc.nextInt(), c=  sc.nextInt(), d = sc.nextInt();
		int sqrt = (int)Math.sqrt(a);
		List<Integer> list = new ArrayList<>();
		if(a<=3){
			System.out.println(1);return;	
		}
		for(int i=2;i<=sqrt;i++){
			for(int ii=2;;ii++){
				if(Math.pow(i,ii)<a){
					list.add((int)Math.pow(i,ii));
				} else if(Math.pow(i,ii)==a){
					list.add((int)Math.pow(i,ii));break;
				} else break;	
			}
		}
		Collections.sort(list);
		System.out.println(list.get(list.size()-1));
	}
} public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//, b = sc.nextInt(), c=  sc.nextInt(), d = sc.nextInt();
		int sqrt = (int)Math.sqrt(a);
		List<Integer> list = new ArrayList<>();
		if(a<=3){
			System.out.println(1);return;	
		}
		for(int i=2;i<=sqrt;i++){
			for(int ii=2;;ii++){
				if(Math.pow(i,ii)<a){
					list.add((int)Math.pow(i,ii));
				} else if(Math.pow(i,ii)==a){
					list.add((int)Math.pow(i,ii));break;
				} else break;	
			}
		}
		Collections.sort(list);
		System.out.println(list.get(list.size()-1));
	}
} Main
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();//, b = sc.nextInt(), c=  sc.nextInt(), d = sc.nextInt();
		int sqrt = (int)Math.sqrt(a);
		List<Integer> list = new ArrayList<>();
		if(a<=3){
			System.out.println(1);return;	
		}
		for(int i=2;i<=sqrt;i++){
			for(int ii=2;;ii++){
				if(Math.pow(i,ii)<a){
					list.add((int)Math.pow(i,ii));
				} else if(Math.pow(i,ii)==a){
					list.add((int)Math.pow(i,ii));break;
				} else break;	
			}
		}
		Collections.sort(list);
		System.out.println(list.get(list.size()-1));
	}
}