import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int max = 1;

    for(int b=1;b<32;b++){
      for(int p=2;p<10;p++){
        double exp = Math.pow(b,p);
        if(exp>X){
          break;
        }
        if(max < exp){
          max = (int)exp;
        }
      }
    }
    System.out.println(max);
  }
} 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 max = 1;

    for(int b=1;b<32;b++){
      for(int p=2;p<10;p++){
        double exp = Math.pow(b,p);
        if(exp>X){
          break;
        }
        if(max < exp){
          max = (int)exp;
        }
      }
    }
    System.out.println(max);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int max = 1;

    for(int b=1;b<32;b++){
      for(int p=2;p<10;p++){
        double exp = Math.pow(b,p);
        if(exp>X){
          break;
        }
        if(max < exp){
          max = (int)exp;
        }
      }
    }
    System.out.println(max);
  } main {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int max = 1;

    for(int b=1;b<32;b++){
      for(int p=2;p<10;p++){
        double exp = Math.pow(b,p);
        if(exp>X){
          break;
        }
        if(max < exp){
          max = (int)exp;
        }
      }
    }
    System.out.println(max);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc int max = 1; max 1 for(int b=1;b<32;b++){
      for(int p=2;p<10;p++){
        double exp = Math.pow(b,p);
        if(exp>X){
          break;
        }
        if(max < exp){
          max = (int)exp;
        }
      }
    } int b=1; int b=1; b 1 b<32 b 32 b++ b++ b {
      for(int p=2;p<10;p++){
        double exp = Math.pow(b,p);
        if(exp>X){
          break;
        }
        if(max < exp){
          max = (int)exp;
        }
      }
    } {
      for(int p=2;p<10;p++){
        double exp = Math.pow(b,p);
        if(exp>X){
          break;
        }
        if(max < exp){
          max = (int)exp;
        }
      }
    } for(int p=2;p<10;p++){
        double exp = Math.pow(b,p);
        if(exp>X){
          break;
        }
        if(max < exp){
          max = (int)exp;
        }
      } int p=2; int p=2; p 2 p<10 p 10 p++ p++ p {
        double exp = Math.pow(b,p);
        if(exp>X){
          break;
        }
        if(max < exp){
          max = (int)exp;
        }
      } {
        double exp = Math.pow(b,p);
        if(exp>X){
          break;
        }
        if(max < exp){
          max = (int)exp;
        }
      } double exp = Math.pow(b,p); exp Math.pow(b,p) Math.pow Math b p if(exp>X){
          break;
        } exp>X exp X {
          break;
        } break; if(max < exp){
          max = (int)exp;
        } max < exp max exp {
          max = (int)exp;
        } max = (int)exp max (int)exp System.out.println(max) System.out.println System.out System System.out max String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int max = 1;

    for(int b=1;b<32;b++){
      for(int p=2;p<10;p++){
        double exp = Math.pow(b,p);
        if(exp>X){
          break;
        }
        if(max < exp){
          max = (int)exp;
        }
      }
    }
    System.out.println(max);
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int max = 1;

    for(int b=1;b<32;b++){
      for(int p=2;p<10;p++){
        double exp = Math.pow(b,p);
        if(exp>X){
          break;
        }
        if(max < exp){
          max = (int)exp;
        }
      }
    }
    System.out.println(max);
  }
} Main
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int max = 1;

    for(int b=1;b<32;b++){
      for(int p=2;p<10;p++){
        double exp = Math.pow(b,p);
        if(exp>X){
          break;
        }
        if(max < exp){
          max = (int)exp;
        }
      }
    }
    System.out.println(max);
  }
}
