import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    
    int max = 1;
    for(int i = 2; i <= Math.sqrt(N); i++){
      int n = i;
      for(int j = 2; n*i <= N; j++){
        n *= i;
      }
      max = max < n ? n : max;
    }
    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 N = Integer.parseInt(sc.nextLine());
    
    int max = 1;
    for(int i = 2; i <= Math.sqrt(N); i++){
      int n = i;
      for(int j = 2; n*i <= N; j++){
        n *= i;
      }
      max = max < n ? n : max;
    }
    System.out.println(max);
  }
} Main public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    
    int max = 1;
    for(int i = 2; i <= Math.sqrt(N); i++){
      int n = i;
      for(int j = 2; n*i <= N; j++){
        n *= i;
      }
      max = max < n ? n : max;
    }
    System.out.println(max);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    
    int max = 1;
    for(int i = 2; i <= Math.sqrt(N); i++){
      int n = i;
      for(int j = 2; n*i <= N; j++){
        n *= i;
      }
      max = max < n ? n : max;
    }
    System.out.println(max);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = Integer.parseInt(sc.nextLine()); N Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc int max = 1; max 1 for(int i = 2; i <= Math.sqrt(N); i++){
      int n = i;
      for(int j = 2; n*i <= N; j++){
        n *= i;
      }
      max = max < n ? n : max;
    } int i = 2; int i = 2; i 2 i <= Math.sqrt(N) i Math.sqrt(N) Math.sqrt Math N i++ i++ i {
      int n = i;
      for(int j = 2; n*i <= N; j++){
        n *= i;
      }
      max = max < n ? n : max;
    } {
      int n = i;
      for(int j = 2; n*i <= N; j++){
        n *= i;
      }
      max = max < n ? n : max;
    } int n = i; n i for(int j = 2; n*i <= N; j++){
        n *= i;
      } int j = 2; int j = 2; j 2 n*i <= N n*i n i N j++ j++ j {
        n *= i;
      } {
        n *= i;
      } n *= i n i max = max < n ? n : max max max < n ? n : max max < n max n n max 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 N = Integer.parseInt(sc.nextLine());
    
    int max = 1;
    for(int i = 2; i <= Math.sqrt(N); i++){
      int n = i;
      for(int j = 2; n*i <= N; j++){
        n *= i;
      }
      max = max < n ? n : max;
    }
    System.out.println(max);
  }
} public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    
    int max = 1;
    for(int i = 2; i <= Math.sqrt(N); i++){
      int n = i;
      for(int j = 2; n*i <= N; j++){
        n *= i;
      }
      max = max < n ? n : max;
    }
    System.out.println(max);
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    
    int max = 1;
    for(int i = 2; i <= Math.sqrt(N); i++){
      int n = i;
      for(int j = 2; n*i <= N; j++){
        n *= i;
      }
      max = max < n ? n : max;
    }
    System.out.println(max);
  }
}