import java.util.Scanner;

class Main{
	int X;

  public static void main(String[] ar){
    new Main();
  }
  public Main(){
  	Scanner sc=new Scanner(System.in);
  	String line=sc.nextLine();
  	X=Integer.parseInt(line);  	
  	//System.out.println(X);
  	
    int E=0;
    for(double r=2;r<=10;r++){
      int a=(int)Math.pow((int)Math.pow(X+0.1, 1.0/r), r);
      if(E<a) E=a;
    } 
    System.out.println(E);
  }
} import java.util.Scanner; Scanner java.util class Main{
	int X;

  public static void main(String[] ar){
    new Main();
  }
  public Main(){
  	Scanner sc=new Scanner(System.in);
  	String line=sc.nextLine();
  	X=Integer.parseInt(line);  	
  	//System.out.println(X);
  	
    int E=0;
    for(double r=2;r<=10;r++){
      int a=(int)Math.pow((int)Math.pow(X+0.1, 1.0/r), r);
      if(E<a) E=a;
    } 
    System.out.println(E);
  }
} Main int X; X public static void main(String[] ar){
    new Main();
  } main {
    new Main();
  } new Main() String[] ar ar public Main(){
  	Scanner sc=new Scanner(System.in);
  	String line=sc.nextLine();
  	X=Integer.parseInt(line);  	
  	//System.out.println(X);
  	
    int E=0;
    for(double r=2;r<=10;r++){
      int a=(int)Math.pow((int)Math.pow(X+0.1, 1.0/r), r);
      if(E<a) E=a;
    } 
    System.out.println(E);
  } Main {
  	Scanner sc=new Scanner(System.in);
  	String line=sc.nextLine();
  	X=Integer.parseInt(line);  	
  	//System.out.println(X);
  	
    int E=0;
    for(double r=2;r<=10;r++){
      int a=(int)Math.pow((int)Math.pow(X+0.1, 1.0/r), r);
      if(E<a) E=a;
    } 
    System.out.println(E);
  } Scanner sc=new Scanner(System.in); sc new Scanner(System.in) String line=sc.nextLine(); line sc.nextLine() sc.nextLine sc X=Integer.parseInt(line) X Integer.parseInt(line) Integer.parseInt Integer line int E=0; E 0 for(double r=2;r<=10;r++){
      int a=(int)Math.pow((int)Math.pow(X+0.1, 1.0/r), r);
      if(E<a) E=a;
    } double r=2; double r=2; r 2 r<=10 r 10 r++ r++ r {
      int a=(int)Math.pow((int)Math.pow(X+0.1, 1.0/r), r);
      if(E<a) E=a;
    } {
      int a=(int)Math.pow((int)Math.pow(X+0.1, 1.0/r), r);
      if(E<a) E=a;
    } int a=(int)Math.pow((int)Math.pow(X+0.1, 1.0/r), r); a (int)Math.pow((int)Math.pow(X+0.1, 1.0/r), r) Math.pow Math (int)Math.pow(X+0.1, 1.0/r) Math.pow Math X+0.1 X 0.1 1.0/r 1.0 r r if(E<a) E=a; E<a E a E=a E a System.out.println(E) System.out.println System.out System System.out E
import java.util.Scanner;

class Main{
	int X;

  public static void main(String[] ar){
    new Main();
  }
  public Main(){
  	Scanner sc=new Scanner(System.in);
  	String line=sc.nextLine();
  	X=Integer.parseInt(line);  	
  	//System.out.println(X);
  	
    int E=0;
    for(double r=2;r<=10;r++){
      int a=(int)Math.pow((int)Math.pow(X+0.1, 1.0/r), r);
      if(E<a) E=a;
    } 
    System.out.println(E);
  }
}