import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    for(int i=X;i>0;i--){
      if(isRui(i)){
        System.out.println(i);
        return;
      }
    }
  }
  
  public static boolean isRui(int n){
     boolean res = false;
    for(int i=1;i<=n;i++){
      for(int j=2;j<12;j++){
        if(Math.pow(i,j)==n){
          return true;
        }
      }
    }
    return res;
  }
  
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    for(int i=X;i>0;i--){
      if(isRui(i)){
        System.out.println(i);
        return;
      }
    }
  }
  
  public static boolean isRui(int n){
     boolean res = false;
    for(int i=1;i<=n;i++){
      for(int j=2;j<12;j++){
        if(Math.pow(i,j)==n){
          return true;
        }
      }
    }
    return res;
  }
  
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    for(int i=X;i>0;i--){
      if(isRui(i)){
        System.out.println(i);
        return;
      }
    }
  } main {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    for(int i=X;i>0;i--){
      if(isRui(i)){
        System.out.println(i);
        return;
      }
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc for(int i=X;i>0;i--){
      if(isRui(i)){
        System.out.println(i);
        return;
      }
    } int i=X; int i=X; i X i>0 i 0 i-- i-- i {
      if(isRui(i)){
        System.out.println(i);
        return;
      }
    } {
      if(isRui(i)){
        System.out.println(i);
        return;
      }
    } if(isRui(i)){
        System.out.println(i);
        return;
      } isRui(i) isRui i {
        System.out.println(i);
        return;
      } System.out.println(i) System.out.println System.out System System.out i return; String[] args args public static boolean isRui(int n){
     boolean res = false;
    for(int i=1;i<=n;i++){
      for(int j=2;j<12;j++){
        if(Math.pow(i,j)==n){
          return true;
        }
      }
    }
    return res;
  } isRui {
     boolean res = false;
    for(int i=1;i<=n;i++){
      for(int j=2;j<12;j++){
        if(Math.pow(i,j)==n){
          return true;
        }
      }
    }
    return res;
  } boolean res = false; res false for(int i=1;i<=n;i++){
      for(int j=2;j<12;j++){
        if(Math.pow(i,j)==n){
          return true;
        }
      }
    } int i=1; int i=1; i 1 i<=n i n i++ i++ i {
      for(int j=2;j<12;j++){
        if(Math.pow(i,j)==n){
          return true;
        }
      }
    } {
      for(int j=2;j<12;j++){
        if(Math.pow(i,j)==n){
          return true;
        }
      }
    } for(int j=2;j<12;j++){
        if(Math.pow(i,j)==n){
          return true;
        }
      } int j=2; int j=2; j 2 j<12 j 12 j++ j++ j {
        if(Math.pow(i,j)==n){
          return true;
        }
      } {
        if(Math.pow(i,j)==n){
          return true;
        }
      } if(Math.pow(i,j)==n){
          return true;
        } Math.pow(i,j)==n Math.pow(i,j) Math.pow Math i j n {
          return true;
        } return true; true return res; res int n n public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    for(int i=X;i>0;i--){
      if(isRui(i)){
        System.out.println(i);
        return;
      }
    }
  }
  
  public static boolean isRui(int n){
     boolean res = false;
    for(int i=1;i<=n;i++){
      for(int j=2;j<12;j++){
        if(Math.pow(i,j)==n){
          return true;
        }
      }
    }
    return res;
  }
  
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    for(int i=X;i>0;i--){
      if(isRui(i)){
        System.out.println(i);
        return;
      }
    }
  }
  
  public static boolean isRui(int n){
     boolean res = false;
    for(int i=1;i<=n;i++){
      for(int j=2;j<12;j++){
        if(Math.pow(i,j)==n){
          return true;
        }
      }
    }
    return res;
  }
  
} Main
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    for(int i=X;i>0;i--){
      if(isRui(i)){
        System.out.println(i);
        return;
      }
    }
  }
  
  public static boolean isRui(int n){
     boolean res = false;
    for(int i=1;i<=n;i++){
      for(int j=2;j<12;j++){
        if(Math.pow(i,j)==n){
          return true;
        }
      }
    }
    return res;
  }
  
}