import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double X = sc.nextDouble();
      	double i;
      	double j;
      	int count = 0;
      	for(i = 1; i <= X / 2 + 1; i++){
          for(j = 1; j <= X / 2 + 1; j++){
            if(count <= (int) Math.pow(i, j) && (int) Math.pow(i, j) <= X){
              count = (int) Math.pow(i, j);
            }
          }
        }
        System.out.println(count);  
    }
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double X = sc.nextDouble();
      	double i;
      	double j;
      	int count = 0;
      	for(i = 1; i <= X / 2 + 1; i++){
          for(j = 1; j <= X / 2 + 1; j++){
            if(count <= (int) Math.pow(i, j) && (int) Math.pow(i, j) <= X){
              count = (int) Math.pow(i, j);
            }
          }
        }
        System.out.println(count);  
    }
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double X = sc.nextDouble();
      	double i;
      	double j;
      	int count = 0;
      	for(i = 1; i <= X / 2 + 1; i++){
          for(j = 1; j <= X / 2 + 1; j++){
            if(count <= (int) Math.pow(i, j) && (int) Math.pow(i, j) <= X){
              count = (int) Math.pow(i, j);
            }
          }
        }
        System.out.println(count);  
    } main {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double X = sc.nextDouble();
      	double i;
      	double j;
      	int count = 0;
      	for(i = 1; i <= X / 2 + 1; i++){
          for(j = 1; j <= X / 2 + 1; j++){
            if(count <= (int) Math.pow(i, j) && (int) Math.pow(i, j) <= X){
              count = (int) Math.pow(i, j);
            }
          }
        }
        System.out.println(count);  
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) double X = sc.nextDouble(); X sc.nextDouble() sc.nextDouble sc double i; i double j; j int count = 0; count 0 for(i = 1; i <= X / 2 + 1; i++){
          for(j = 1; j <= X / 2 + 1; j++){
            if(count <= (int) Math.pow(i, j) && (int) Math.pow(i, j) <= X){
              count = (int) Math.pow(i, j);
            }
          }
        } i = 1; i = 1 i 1 i <= X / 2 + 1 i X / 2 + 1 X / 2 X 2 1 i++ i++ i {
          for(j = 1; j <= X / 2 + 1; j++){
            if(count <= (int) Math.pow(i, j) && (int) Math.pow(i, j) <= X){
              count = (int) Math.pow(i, j);
            }
          }
        } {
          for(j = 1; j <= X / 2 + 1; j++){
            if(count <= (int) Math.pow(i, j) && (int) Math.pow(i, j) <= X){
              count = (int) Math.pow(i, j);
            }
          }
        } for(j = 1; j <= X / 2 + 1; j++){
            if(count <= (int) Math.pow(i, j) && (int) Math.pow(i, j) <= X){
              count = (int) Math.pow(i, j);
            }
          } j = 1; j = 1 j 1 j <= X / 2 + 1 j X / 2 + 1 X / 2 X 2 1 j++ j++ j {
            if(count <= (int) Math.pow(i, j) && (int) Math.pow(i, j) <= X){
              count = (int) Math.pow(i, j);
            }
          } {
            if(count <= (int) Math.pow(i, j) && (int) Math.pow(i, j) <= X){
              count = (int) Math.pow(i, j);
            }
          } if(count <= (int) Math.pow(i, j) && (int) Math.pow(i, j) <= X){
              count = (int) Math.pow(i, j);
            } count <= (int) Math.pow(i, j) && (int) Math.pow(i, j) <= X count <= (int) Math.pow(i, j) count (int) Math.pow(i, j) Math.pow Math i j (int) Math.pow(i, j) <= X (int) Math.pow(i, j) Math.pow Math i j X {
              count = (int) Math.pow(i, j);
            } count = (int) Math.pow(i, j) count (int) Math.pow(i, j) Math.pow Math i j System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double X = sc.nextDouble();
      	double i;
      	double j;
      	int count = 0;
      	for(i = 1; i <= X / 2 + 1; i++){
          for(j = 1; j <= X / 2 + 1; j++){
            if(count <= (int) Math.pow(i, j) && (int) Math.pow(i, j) <= X){
              count = (int) Math.pow(i, j);
            }
          }
        }
        System.out.println(count);  
    }
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double X = sc.nextDouble();
      	double i;
      	double j;
      	int count = 0;
      	for(i = 1; i <= X / 2 + 1; i++){
          for(j = 1; j <= X / 2 + 1; j++){
            if(count <= (int) Math.pow(i, j) && (int) Math.pow(i, j) <= X){
              count = (int) Math.pow(i, j);
            }
          }
        }
        System.out.println(count);  
    }
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		double X = sc.nextDouble();
      	double i;
      	double j;
      	int count = 0;
      	for(i = 1; i <= X / 2 + 1; i++){
          for(j = 1; j <= X / 2 + 1; j++){
            if(count <= (int) Math.pow(i, j) && (int) Math.pow(i, j) <= X){
              count = (int) Math.pow(i, j);
            }
          }
        }
        System.out.println(count);  
    }
}