import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int count = 0;
    
    //x以下の間繰り返す
    for(int i = 0; i <= x; ++i){
      //1からべき乗か調べる
      for(int j = 2; j <= x; ++j){
        if((Math.pow(i,j)<= x) && (count<Math.pow(i,j))){
          count = (int)Math.pow(i,j);
        }
      }
    }
    if(count==0){
      count = 1;
    }
    System.out.println(count);
    
  }
} 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 count = 0;
    
    //x以下の間繰り返す
    for(int i = 0; i <= x; ++i){
      //1からべき乗か調べる
      for(int j = 2; j <= x; ++j){
        if((Math.pow(i,j)<= x) && (count<Math.pow(i,j))){
          count = (int)Math.pow(i,j);
        }
      }
    }
    if(count==0){
      count = 1;
    }
    System.out.println(count);
    
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int count = 0;
    
    //x以下の間繰り返す
    for(int i = 0; i <= x; ++i){
      //1からべき乗か調べる
      for(int j = 2; j <= x; ++j){
        if((Math.pow(i,j)<= x) && (count<Math.pow(i,j))){
          count = (int)Math.pow(i,j);
        }
      }
    }
    if(count==0){
      count = 1;
    }
    System.out.println(count);
    
  } main {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int count = 0;
    
    //x以下の間繰り返す
    for(int i = 0; i <= x; ++i){
      //1からべき乗か調べる
      for(int j = 2; j <= x; ++j){
        if((Math.pow(i,j)<= x) && (count<Math.pow(i,j))){
          count = (int)Math.pow(i,j);
        }
      }
    }
    if(count==0){
      count = 1;
    }
    System.out.println(count);
    
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int count = 0; count 0 for(int i = 0; i <= x; ++i){
      //1からべき乗か調べる
      for(int j = 2; j <= x; ++j){
        if((Math.pow(i,j)<= x) && (count<Math.pow(i,j))){
          count = (int)Math.pow(i,j);
        }
      }
    } int i = 0; int i = 0; i 0 i <= x i x ++i ++i i {
      //1からべき乗か調べる
      for(int j = 2; j <= x; ++j){
        if((Math.pow(i,j)<= x) && (count<Math.pow(i,j))){
          count = (int)Math.pow(i,j);
        }
      }
    } {
      //1からべき乗か調べる
      for(int j = 2; j <= x; ++j){
        if((Math.pow(i,j)<= x) && (count<Math.pow(i,j))){
          count = (int)Math.pow(i,j);
        }
      }
    } for(int j = 2; j <= x; ++j){
        if((Math.pow(i,j)<= x) && (count<Math.pow(i,j))){
          count = (int)Math.pow(i,j);
        }
      } int j = 2; int j = 2; j 2 j <= x j x ++j ++j j {
        if((Math.pow(i,j)<= x) && (count<Math.pow(i,j))){
          count = (int)Math.pow(i,j);
        }
      } {
        if((Math.pow(i,j)<= x) && (count<Math.pow(i,j))){
          count = (int)Math.pow(i,j);
        }
      } if((Math.pow(i,j)<= x) && (count<Math.pow(i,j))){
          count = (int)Math.pow(i,j);
        } (Math.pow(i,j)<= x) && (count<Math.pow(i,j)) (Math.pow(i,j)<= x) Math.pow(i,j) Math.pow Math i j x (count<Math.pow(i,j)) count Math.pow(i,j) Math.pow Math i j {
          count = (int)Math.pow(i,j);
        } count = (int)Math.pow(i,j) count (int)Math.pow(i,j) Math.pow Math i j if(count==0){
      count = 1;
    } count==0 count 0 {
      count = 1;
    } count = 1 count 1 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);
    int x = sc.nextInt();
    int count = 0;
    
    //x以下の間繰り返す
    for(int i = 0; i <= x; ++i){
      //1からべき乗か調べる
      for(int j = 2; j <= x; ++j){
        if((Math.pow(i,j)<= x) && (count<Math.pow(i,j))){
          count = (int)Math.pow(i,j);
        }
      }
    }
    if(count==0){
      count = 1;
    }
    System.out.println(count);
    
  }
} public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int count = 0;
    
    //x以下の間繰り返す
    for(int i = 0; i <= x; ++i){
      //1からべき乗か調べる
      for(int j = 2; j <= x; ++j){
        if((Math.pow(i,j)<= x) && (count<Math.pow(i,j))){
          count = (int)Math.pow(i,j);
        }
      }
    }
    if(count==0){
      count = 1;
    }
    System.out.println(count);
    
  }
} Main
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int count = 0;
    
    //x以下の間繰り返す
    for(int i = 0; i <= x; ++i){
      //1からべき乗か調べる
      for(int j = 2; j <= x; ++j){
        if((Math.pow(i,j)<= x) && (count<Math.pow(i,j))){
          count = (int)Math.pow(i,j);
        }
      }
    }
    if(count==0){
      count = 1;
    }
    System.out.println(count);
    
  }
}