import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int i=0;
    //べき乗数を後ろから探す
    for(i=X;i>0;i--){
      if(judge(i)){
        break;
      }
    }
    System.out.println(i);
  }
    //べき乗数かどうか
    private static boolean judge(int n){
      boolean re = false;
      if(n==1){//１のとき
        re = true;
      }else{//１以外なら
        for(int i=2;i<n;i++){
          for(int j=1;j<n;j++){
            int m = (int)Math.pow(i,j);
            if(m==n){
              re = true;
              break;
            }
          }
        }
      }
        return re;
      }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int i=0;
    //べき乗数を後ろから探す
    for(i=X;i>0;i--){
      if(judge(i)){
        break;
      }
    }
    System.out.println(i);
  }
    //べき乗数かどうか
    private static boolean judge(int n){
      boolean re = false;
      if(n==1){//１のとき
        re = true;
      }else{//１以外なら
        for(int i=2;i<n;i++){
          for(int j=1;j<n;j++){
            int m = (int)Math.pow(i,j);
            if(m==n){
              re = true;
              break;
            }
          }
        }
      }
        return re;
      }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int i=0;
    //べき乗数を後ろから探す
    for(i=X;i>0;i--){
      if(judge(i)){
        break;
      }
    }
    System.out.println(i);
  } main {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int i=0;
    //べき乗数を後ろから探す
    for(i=X;i>0;i--){
      if(judge(i)){
        break;
      }
    }
    System.out.println(i);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc int i=0; i 0 for(i=X;i>0;i--){
      if(judge(i)){
        break;
      }
    } i=X; i=X i X i>0 i 0 i-- i-- i {
      if(judge(i)){
        break;
      }
    } {
      if(judge(i)){
        break;
      }
    } if(judge(i)){
        break;
      } judge(i) judge i {
        break;
      } break; System.out.println(i) System.out.println System.out System System.out i String[] args args //べき乗数かどうか
    private static boolean judge(int n){
      boolean re = false;
      if(n==1){//１のとき
        re = true;
      }else{//１以外なら
        for(int i=2;i<n;i++){
          for(int j=1;j<n;j++){
            int m = (int)Math.pow(i,j);
            if(m==n){
              re = true;
              break;
            }
          }
        }
      }
        return re;
      } judge {
      boolean re = false;
      if(n==1){//１のとき
        re = true;
      }else{//１以外なら
        for(int i=2;i<n;i++){
          for(int j=1;j<n;j++){
            int m = (int)Math.pow(i,j);
            if(m==n){
              re = true;
              break;
            }
          }
        }
      }
        return re;
      } boolean re = false; re false if(n==1){//１のとき
        re = true;
      }else{//１以外なら
        for(int i=2;i<n;i++){
          for(int j=1;j<n;j++){
            int m = (int)Math.pow(i,j);
            if(m==n){
              re = true;
              break;
            }
          }
        }
      } n==1 n 1 {//１のとき
        re = true;
      } re = true re true {//１以外なら
        for(int i=2;i<n;i++){
          for(int j=1;j<n;j++){
            int m = (int)Math.pow(i,j);
            if(m==n){
              re = true;
              break;
            }
          }
        }
      } for(int i=2;i<n;i++){
          for(int j=1;j<n;j++){
            int m = (int)Math.pow(i,j);
            if(m==n){
              re = true;
              break;
            }
          }
        } int i=2; int i=2; i 2 i<n i n i++ i++ i {
          for(int j=1;j<n;j++){
            int m = (int)Math.pow(i,j);
            if(m==n){
              re = true;
              break;
            }
          }
        } {
          for(int j=1;j<n;j++){
            int m = (int)Math.pow(i,j);
            if(m==n){
              re = true;
              break;
            }
          }
        } for(int j=1;j<n;j++){
            int m = (int)Math.pow(i,j);
            if(m==n){
              re = true;
              break;
            }
          } int j=1; int j=1; j 1 j<n j n j++ j++ j {
            int m = (int)Math.pow(i,j);
            if(m==n){
              re = true;
              break;
            }
          } {
            int m = (int)Math.pow(i,j);
            if(m==n){
              re = true;
              break;
            }
          } int m = (int)Math.pow(i,j); m (int)Math.pow(i,j) Math.pow Math i j if(m==n){
              re = true;
              break;
            } m==n m n {
              re = true;
              break;
            } re = true re true break; return re; re int n n public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int i=0;
    //べき乗数を後ろから探す
    for(i=X;i>0;i--){
      if(judge(i)){
        break;
      }
    }
    System.out.println(i);
  }
    //べき乗数かどうか
    private static boolean judge(int n){
      boolean re = false;
      if(n==1){//１のとき
        re = true;
      }else{//１以外なら
        for(int i=2;i<n;i++){
          for(int j=1;j<n;j++){
            int m = (int)Math.pow(i,j);
            if(m==n){
              re = true;
              break;
            }
          }
        }
      }
        return re;
      }
} public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int i=0;
    //べき乗数を後ろから探す
    for(i=X;i>0;i--){
      if(judge(i)){
        break;
      }
    }
    System.out.println(i);
  }
    //べき乗数かどうか
    private static boolean judge(int n){
      boolean re = false;
      if(n==1){//１のとき
        re = true;
      }else{//１以外なら
        for(int i=2;i<n;i++){
          for(int j=1;j<n;j++){
            int m = (int)Math.pow(i,j);
            if(m==n){
              re = true;
              break;
            }
          }
        }
      }
        return re;
      }
} Main
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int i=0;
    //べき乗数を後ろから探す
    for(i=X;i>0;i--){
      if(judge(i)){
        break;
      }
    }
    System.out.println(i);
  }
    //べき乗数かどうか
    private static boolean judge(int n){
      boolean re = false;
      if(n==1){//１のとき
        re = true;
      }else{//１以外なら
        for(int i=2;i<n;i++){
          for(int j=1;j<n;j++){
            int m = (int)Math.pow(i,j);
            if(m==n){
              re = true;
              break;
            }
          }
        }
      }
        return re;
      }
}