import java.util.*;
import java.lang.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int MAX_ROOT = (int)Math.sqrt(x);
    double e = 1;
    double max = e;
    for(int i = 2;i <= MAX_ROOT;i++){
      for(int j = 1;j <= 9;j++){
        e = Math.pow(i,j);
        if(e > x) break;
        if(max < e){
          max = e;
        }
      }
    }
    int emax = (int)max;
    System.out.println(emax);
  }
} import java.util.*; util.* java import java.lang.*; lang.* java class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int MAX_ROOT = (int)Math.sqrt(x);
    double e = 1;
    double max = e;
    for(int i = 2;i <= MAX_ROOT;i++){
      for(int j = 1;j <= 9;j++){
        e = Math.pow(i,j);
        if(e > x) break;
        if(max < e){
          max = e;
        }
      }
    }
    int emax = (int)max;
    System.out.println(emax);
  }
} Main public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int MAX_ROOT = (int)Math.sqrt(x);
    double e = 1;
    double max = e;
    for(int i = 2;i <= MAX_ROOT;i++){
      for(int j = 1;j <= 9;j++){
        e = Math.pow(i,j);
        if(e > x) break;
        if(max < e){
          max = e;
        }
      }
    }
    int emax = (int)max;
    System.out.println(emax);
  } main {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int MAX_ROOT = (int)Math.sqrt(x);
    double e = 1;
    double max = e;
    for(int i = 2;i <= MAX_ROOT;i++){
      for(int j = 1;j <= 9;j++){
        e = Math.pow(i,j);
        if(e > x) break;
        if(max < e){
          max = e;
        }
      }
    }
    int emax = (int)max;
    System.out.println(emax);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int MAX_ROOT = (int)Math.sqrt(x); MAX_ROOT (int)Math.sqrt(x) Math.sqrt Math x double e = 1; e 1 double max = e; max e for(int i = 2;i <= MAX_ROOT;i++){
      for(int j = 1;j <= 9;j++){
        e = Math.pow(i,j);
        if(e > x) break;
        if(max < e){
          max = e;
        }
      }
    } int i = 2; int i = 2; i 2 i <= MAX_ROOT i MAX_ROOT i++ i++ i {
      for(int j = 1;j <= 9;j++){
        e = Math.pow(i,j);
        if(e > x) break;
        if(max < e){
          max = e;
        }
      }
    } {
      for(int j = 1;j <= 9;j++){
        e = Math.pow(i,j);
        if(e > x) break;
        if(max < e){
          max = e;
        }
      }
    } for(int j = 1;j <= 9;j++){
        e = Math.pow(i,j);
        if(e > x) break;
        if(max < e){
          max = e;
        }
      } int j = 1; int j = 1; j 1 j <= 9 j 9 j++ j++ j {
        e = Math.pow(i,j);
        if(e > x) break;
        if(max < e){
          max = e;
        }
      } {
        e = Math.pow(i,j);
        if(e > x) break;
        if(max < e){
          max = e;
        }
      } e = Math.pow(i,j) e Math.pow(i,j) Math.pow Math i j if(e > x) break; e > x e x break; if(max < e){
          max = e;
        } max < e max e {
          max = e;
        } max = e max e int emax = (int)max; emax (int)max System.out.println(emax) System.out.println System.out System System.out emax String args[] args
import java.util.*;
import java.lang.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int MAX_ROOT = (int)Math.sqrt(x);
    double e = 1;
    double max = e;
    for(int i = 2;i <= MAX_ROOT;i++){
      for(int j = 1;j <= 9;j++){
        e = Math.pow(i,j);
        if(e > x) break;
        if(max < e){
          max = e;
        }
      }
    }
    int emax = (int)max;
    System.out.println(emax);
  }
}