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

  private static int factor(int a, int n) {
    if(n == 0)
      return 1;
    if(n == 1)
      return a;
    int fac = factor(a, n / 2);
    return n % 2 == 0 ? fac*fac : fac*fac * a;
  }
} 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;
      int cur = 1;
      
      for(int i = 2; i * i <= x; i++) {
        int fac = 1;
        while(factor(i, fac + 1) <= x)
          fac++;
        max = Math.max(max, (int)Math.pow(i, fac));
      }
      System.out.println(max);
  }

  private static int factor(int a, int n) {
    if(n == 0)
      return 1;
    if(n == 1)
      return a;
    int fac = factor(a, n / 2);
    return n % 2 == 0 ? fac*fac : fac*fac * a;
  }
} Main public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();

      int max = 1;
      int cur = 1;
      
      for(int i = 2; i * i <= x; i++) {
        int fac = 1;
        while(factor(i, fac + 1) <= x)
          fac++;
        max = Math.max(max, (int)Math.pow(i, fac));
      }
      System.out.println(max);
  } main { 
      Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();

      int max = 1;
      int cur = 1;
      
      for(int i = 2; i * i <= x; i++) {
        int fac = 1;
        while(factor(i, fac + 1) <= x)
          fac++;
        max = Math.max(max, (int)Math.pow(i, fac));
      }
      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 int cur = 1; cur 1 for(int i = 2; i * i <= x; i++) {
        int fac = 1;
        while(factor(i, fac + 1) <= x)
          fac++;
        max = Math.max(max, (int)Math.pow(i, fac));
      } int i = 2; int i = 2; i 2 i * i <= x i * i i i x i++ i++ i {
        int fac = 1;
        while(factor(i, fac + 1) <= x)
          fac++;
        max = Math.max(max, (int)Math.pow(i, fac));
      } {
        int fac = 1;
        while(factor(i, fac + 1) <= x)
          fac++;
        max = Math.max(max, (int)Math.pow(i, fac));
      } int fac = 1; fac 1 while(factor(i, fac + 1) <= x)
          fac++; factor(i, fac + 1) <= x factor(i, fac + 1) factor i fac + 1 fac 1 x fac++ fac max = Math.max(max, (int)Math.pow(i, fac)) max Math.max(max, (int)Math.pow(i, fac)) Math.max Math max (int)Math.pow(i, fac) Math.pow Math i fac System.out.println(max) System.out.println System.out System System.out max String[] args args private static int factor(int a, int n) {
    if(n == 0)
      return 1;
    if(n == 1)
      return a;
    int fac = factor(a, n / 2);
    return n % 2 == 0 ? fac*fac : fac*fac * a;
  } factor {
    if(n == 0)
      return 1;
    if(n == 1)
      return a;
    int fac = factor(a, n / 2);
    return n % 2 == 0 ? fac*fac : fac*fac * a;
  } if(n == 0)
      return 1; n == 0 n 0 return 1; 1 if(n == 1)
      return a; n == 1 n 1 return a; a int fac = factor(a, n / 2); fac factor(a, n / 2) factor a n / 2 n 2 return n % 2 == 0 ? fac*fac : fac*fac * a; n % 2 == 0 ? fac*fac : fac*fac * a n % 2 == 0 n % 2 n 2 0 fac*fac fac fac fac*fac * a fac*fac * a fac fac a int a a int n n public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();

      int max = 1;
      int cur = 1;
      
      for(int i = 2; i * i <= x; i++) {
        int fac = 1;
        while(factor(i, fac + 1) <= x)
          fac++;
        max = Math.max(max, (int)Math.pow(i, fac));
      }
      System.out.println(max);
  }

  private static int factor(int a, int n) {
    if(n == 0)
      return 1;
    if(n == 1)
      return a;
    int fac = factor(a, n / 2);
    return n % 2 == 0 ? fac*fac : fac*fac * a;
  }
} public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();

      int max = 1;
      int cur = 1;
      
      for(int i = 2; i * i <= x; i++) {
        int fac = 1;
        while(factor(i, fac + 1) <= x)
          fac++;
        max = Math.max(max, (int)Math.pow(i, fac));
      }
      System.out.println(max);
  }

  private static int factor(int a, int n) {
    if(n == 0)
      return 1;
    if(n == 1)
      return a;
    int fac = factor(a, n / 2);
    return n % 2 == 0 ? fac*fac : fac*fac * a;
  }
} 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;
      int cur = 1;
      
      for(int i = 2; i * i <= x; i++) {
        int fac = 1;
        while(factor(i, fac + 1) <= x)
          fac++;
        max = Math.max(max, (int)Math.pow(i, fac));
      }
      System.out.println(max);
  }

  private static int factor(int a, int n) {
    if(n == 0)
      return 1;
    if(n == 1)
      return a;
    int fac = factor(a, n / 2);
    return n % 2 == 0 ? fac*fac : fac*fac * a;
  }
}
