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 i = 2; i * i <= x; i++) {
        int num = i;
        while(num * i <= x)
          num *= i;
        max = Math.max(max, num);
      }
      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 i = 2; i * i <= x; i++) {
        int num = i;
        while(num * i <= x)
          num *= i;
        max = Math.max(max, num);
      }
      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 i = 2; i * i <= x; i++) {
        int num = i;
        while(num * i <= x)
          num *= i;
        max = Math.max(max, num);
      }
      System.out.println(max);
  } main { 
      Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();

      int max = 1;
      
      for(int i = 2; i * i <= x; i++) {
        int num = i;
        while(num * i <= x)
          num *= i;
        max = Math.max(max, num);
      }
      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 i = 2; i * i <= x; i++) {
        int num = i;
        while(num * i <= x)
          num *= i;
        max = Math.max(max, num);
      } int i = 2; int i = 2; i 2 i * i <= x i * i i i x i++ i++ i {
        int num = i;
        while(num * i <= x)
          num *= i;
        max = Math.max(max, num);
      } {
        int num = i;
        while(num * i <= x)
          num *= i;
        max = Math.max(max, num);
      } int num = i; num i while(num * i <= x)
          num *= i; num * i <= x num * i num i x num *= i num i max = Math.max(max, num) max Math.max(max, num) Math.max Math max num 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 i = 2; i * i <= x; i++) {
        int num = i;
        while(num * i <= x)
          num *= i;
        max = Math.max(max, num);
      }
      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 i = 2; i * i <= x; i++) {
        int num = i;
        while(num * i <= x)
          num *= i;
        max = Math.max(max, num);
      }
      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 i = 2; i * i <= x; i++) {
        int num = i;
        while(num * i <= x)
          num *= i;
        max = Math.max(max, num);
      }
      System.out.println(max);
  }

}
