import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in); 
		int a = Integer.parseInt(scanner.next());
		if(a<=3){
			System.out.println("1");
			return;
		}
		
		int maxBeki=0;
		int i =0;
		int j =0;
		for(i=2;;i++){
			int maxBekiLine=0;
			int tmpBekiLine=i;			
			for(j=2;;j++){
				tmpBekiLine =tmpBekiLine*i; 
				if(tmpBekiLine>a){
					break;
				}
				maxBekiLine=tmpBekiLine;
			}			
			
			if(maxBekiLine>maxBeki){
				maxBeki = maxBekiLine;
			}
			if(j==2){
				break;
			}
		}
		System.out.println(maxBeki);		
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in); 
		int a = Integer.parseInt(scanner.next());
		if(a<=3){
			System.out.println("1");
			return;
		}
		
		int maxBeki=0;
		int i =0;
		int j =0;
		for(i=2;;i++){
			int maxBekiLine=0;
			int tmpBekiLine=i;			
			for(j=2;;j++){
				tmpBekiLine =tmpBekiLine*i; 
				if(tmpBekiLine>a){
					break;
				}
				maxBekiLine=tmpBekiLine;
			}			
			
			if(maxBekiLine>maxBeki){
				maxBeki = maxBekiLine;
			}
			if(j==2){
				break;
			}
		}
		System.out.println(maxBeki);		
	}
} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in); 
		int a = Integer.parseInt(scanner.next());
		if(a<=3){
			System.out.println("1");
			return;
		}
		
		int maxBeki=0;
		int i =0;
		int j =0;
		for(i=2;;i++){
			int maxBekiLine=0;
			int tmpBekiLine=i;			
			for(j=2;;j++){
				tmpBekiLine =tmpBekiLine*i; 
				if(tmpBekiLine>a){
					break;
				}
				maxBekiLine=tmpBekiLine;
			}			
			
			if(maxBekiLine>maxBeki){
				maxBeki = maxBekiLine;
			}
			if(j==2){
				break;
			}
		}
		System.out.println(maxBeki);		
	} main {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in); 
		int a = Integer.parseInt(scanner.next());
		if(a<=3){
			System.out.println("1");
			return;
		}
		
		int maxBeki=0;
		int i =0;
		int j =0;
		for(i=2;;i++){
			int maxBekiLine=0;
			int tmpBekiLine=i;			
			for(j=2;;j++){
				tmpBekiLine =tmpBekiLine*i; 
				if(tmpBekiLine>a){
					break;
				}
				maxBekiLine=tmpBekiLine;
			}			
			
			if(maxBekiLine>maxBeki){
				maxBeki = maxBekiLine;
			}
			if(j==2){
				break;
			}
		}
		System.out.println(maxBeki);		
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int a = Integer.parseInt(scanner.next()); a Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner 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; int maxBeki=0; maxBeki 0 int i =0; i 0 int j =0; j 0 for(i=2;;i++){
			int maxBekiLine=0;
			int tmpBekiLine=i;			
			for(j=2;;j++){
				tmpBekiLine =tmpBekiLine*i; 
				if(tmpBekiLine>a){
					break;
				}
				maxBekiLine=tmpBekiLine;
			}			
			
			if(maxBekiLine>maxBeki){
				maxBeki = maxBekiLine;
			}
			if(j==2){
				break;
			}
		} i=2; i=2 i 2 i++ i++ i {
			int maxBekiLine=0;
			int tmpBekiLine=i;			
			for(j=2;;j++){
				tmpBekiLine =tmpBekiLine*i; 
				if(tmpBekiLine>a){
					break;
				}
				maxBekiLine=tmpBekiLine;
			}			
			
			if(maxBekiLine>maxBeki){
				maxBeki = maxBekiLine;
			}
			if(j==2){
				break;
			}
		} {
			int maxBekiLine=0;
			int tmpBekiLine=i;			
			for(j=2;;j++){
				tmpBekiLine =tmpBekiLine*i; 
				if(tmpBekiLine>a){
					break;
				}
				maxBekiLine=tmpBekiLine;
			}			
			
			if(maxBekiLine>maxBeki){
				maxBeki = maxBekiLine;
			}
			if(j==2){
				break;
			}
		} int maxBekiLine=0; maxBekiLine 0 int tmpBekiLine=i; tmpBekiLine i for(j=2;;j++){
				tmpBekiLine =tmpBekiLine*i; 
				if(tmpBekiLine>a){
					break;
				}
				maxBekiLine=tmpBekiLine;
			} j=2; j=2 j 2 j++ j++ j {
				tmpBekiLine =tmpBekiLine*i; 
				if(tmpBekiLine>a){
					break;
				}
				maxBekiLine=tmpBekiLine;
			} {
				tmpBekiLine =tmpBekiLine*i; 
				if(tmpBekiLine>a){
					break;
				}
				maxBekiLine=tmpBekiLine;
			} tmpBekiLine =tmpBekiLine*i tmpBekiLine tmpBekiLine*i tmpBekiLine i if(tmpBekiLine>a){
					break;
				} tmpBekiLine>a tmpBekiLine a {
					break;
				} break; maxBekiLine=tmpBekiLine maxBekiLine tmpBekiLine if(maxBekiLine>maxBeki){
				maxBeki = maxBekiLine;
			} maxBekiLine>maxBeki maxBekiLine maxBeki {
				maxBeki = maxBekiLine;
			} maxBeki = maxBekiLine maxBeki maxBekiLine if(j==2){
				break;
			} j==2 j 2 {
				break;
			} break; System.out.println(maxBeki) System.out.println System.out System System.out maxBeki String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in); 
		int a = Integer.parseInt(scanner.next());
		if(a<=3){
			System.out.println("1");
			return;
		}
		
		int maxBeki=0;
		int i =0;
		int j =0;
		for(i=2;;i++){
			int maxBekiLine=0;
			int tmpBekiLine=i;			
			for(j=2;;j++){
				tmpBekiLine =tmpBekiLine*i; 
				if(tmpBekiLine>a){
					break;
				}
				maxBekiLine=tmpBekiLine;
			}			
			
			if(maxBekiLine>maxBeki){
				maxBeki = maxBekiLine;
			}
			if(j==2){
				break;
			}
		}
		System.out.println(maxBeki);		
	}
} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in); 
		int a = Integer.parseInt(scanner.next());
		if(a<=3){
			System.out.println("1");
			return;
		}
		
		int maxBeki=0;
		int i =0;
		int j =0;
		for(i=2;;i++){
			int maxBekiLine=0;
			int tmpBekiLine=i;			
			for(j=2;;j++){
				tmpBekiLine =tmpBekiLine*i; 
				if(tmpBekiLine>a){
					break;
				}
				maxBekiLine=tmpBekiLine;
			}			
			
			if(maxBekiLine>maxBeki){
				maxBeki = maxBekiLine;
			}
			if(j==2){
				break;
			}
		}
		System.out.println(maxBeki);		
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in); 
		int a = Integer.parseInt(scanner.next());
		if(a<=3){
			System.out.println("1");
			return;
		}
		
		int maxBeki=0;
		int i =0;
		int j =0;
		for(i=2;;i++){
			int maxBekiLine=0;
			int tmpBekiLine=i;			
			for(j=2;;j++){
				tmpBekiLine =tmpBekiLine*i; 
				if(tmpBekiLine>a){
					break;
				}
				maxBekiLine=tmpBekiLine;
			}			
			
			if(maxBekiLine>maxBeki){
				maxBeki = maxBekiLine;
			}
			if(j==2){
				break;
			}
		}
		System.out.println(maxBeki);		
	}
}
