import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int ans = 0;
    for (int i = 2; i <= 9; i++) {
      for (int j = 0; j <= 31; j++) {
        if (X >= (int) Math.pow(j, i)) {
          ans = Math.max(ans, (int) Math.pow(j, i));
        }
      }  
    }
    System.out.println(ans);
  }
} 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 ans = 0;
    for (int i = 2; i <= 9; i++) {
      for (int j = 0; j <= 31; j++) {
        if (X >= (int) Math.pow(j, i)) {
          ans = Math.max(ans, (int) Math.pow(j, i));
        }
      }  
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int ans = 0;
    for (int i = 2; i <= 9; i++) {
      for (int j = 0; j <= 31; j++) {
        if (X >= (int) Math.pow(j, i)) {
          ans = Math.max(ans, (int) Math.pow(j, i));
        }
      }  
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int ans = 0;
    for (int i = 2; i <= 9; i++) {
      for (int j = 0; j <= 31; j++) {
        if (X >= (int) Math.pow(j, i)) {
          ans = Math.max(ans, (int) Math.pow(j, i));
        }
      }  
    }
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc int ans = 0; ans 0 for (int i = 2; i <= 9; i++) {
      for (int j = 0; j <= 31; j++) {
        if (X >= (int) Math.pow(j, i)) {
          ans = Math.max(ans, (int) Math.pow(j, i));
        }
      }  
    } int i = 2; int i = 2; i 2 i <= 9 i 9 i++ i++ i {
      for (int j = 0; j <= 31; j++) {
        if (X >= (int) Math.pow(j, i)) {
          ans = Math.max(ans, (int) Math.pow(j, i));
        }
      }  
    } {
      for (int j = 0; j <= 31; j++) {
        if (X >= (int) Math.pow(j, i)) {
          ans = Math.max(ans, (int) Math.pow(j, i));
        }
      }  
    } for (int j = 0; j <= 31; j++) {
        if (X >= (int) Math.pow(j, i)) {
          ans = Math.max(ans, (int) Math.pow(j, i));
        }
      } int j = 0; int j = 0; j 0 j <= 31 j 31 j++ j++ j {
        if (X >= (int) Math.pow(j, i)) {
          ans = Math.max(ans, (int) Math.pow(j, i));
        }
      } {
        if (X >= (int) Math.pow(j, i)) {
          ans = Math.max(ans, (int) Math.pow(j, i));
        }
      } if (X >= (int) Math.pow(j, i)) {
          ans = Math.max(ans, (int) Math.pow(j, i));
        } X >= (int) Math.pow(j, i) X (int) Math.pow(j, i) Math.pow Math j i {
          ans = Math.max(ans, (int) Math.pow(j, i));
        } ans = Math.max(ans, (int) Math.pow(j, i)) ans Math.max(ans, (int) Math.pow(j, i)) Math.max Math ans (int) Math.pow(j, i) Math.pow Math j i System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int ans = 0;
    for (int i = 2; i <= 9; i++) {
      for (int j = 0; j <= 31; j++) {
        if (X >= (int) Math.pow(j, i)) {
          ans = Math.max(ans, (int) Math.pow(j, i));
        }
      }  
    }
    System.out.println(ans);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int ans = 0;
    for (int i = 2; i <= 9; i++) {
      for (int j = 0; j <= 31; j++) {
        if (X >= (int) Math.pow(j, i)) {
          ans = Math.max(ans, (int) Math.pow(j, i));
        }
      }  
    }
    System.out.println(ans);
  }
} Main
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int ans = 0;
    for (int i = 2; i <= 9; i++) {
      for (int j = 0; j <= 31; j++) {
        if (X >= (int) Math.pow(j, i)) {
          ans = Math.max(ans, (int) Math.pow(j, i));
        }
      }  
    }
    System.out.println(ans);
  }
}