import java.util.*;

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int ans = 1;
      for (int i=2;i<=Math.floor(Math.sqrt(X));i++){
       
        int tmp = i;
        while (tmp<=X){
          if (tmp*i <= X){
            tmp *= i;
          }
          else{
            ans = Math.max(ans,tmp);
            break;
          }
        }
      }
      System.out.println(ans);
    }
}