import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    ArrayList<Integer> expo = new ArrayList<>();
    for (int b = 1; b <= 1000; b++) {
      int tmp = b;
      for (int p = 2; p <= 9; p++) {
        tmp *= b;
        if (tmp <= x) {
          expo.add(tmp);
        }
      }
    }
    Collections.sort(expo);
    System.out.println(expo.get(expo.size() - 1));
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    ArrayList<Integer> expo = new ArrayList<>();
    for (int b = 1; b <= 1000; b++) {
      int tmp = b;
      for (int p = 2; p <= 9; p++) {
        tmp *= b;
        if (tmp <= x) {
          expo.add(tmp);
        }
      }
    }
    Collections.sort(expo);
    System.out.println(expo.get(expo.size() - 1));
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    ArrayList<Integer> expo = new ArrayList<>();
    for (int b = 1; b <= 1000; b++) {
      int tmp = b;
      for (int p = 2; p <= 9; p++) {
        tmp *= b;
        if (tmp <= x) {
          expo.add(tmp);
        }
      }
    }
    Collections.sort(expo);
    System.out.println(expo.get(expo.size() - 1));
  } main {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    ArrayList<Integer> expo = new ArrayList<>();
    for (int b = 1; b <= 1000; b++) {
      int tmp = b;
      for (int p = 2; p <= 9; p++) {
        tmp *= b;
        if (tmp <= x) {
          expo.add(tmp);
        }
      }
    }
    Collections.sort(expo);
    System.out.println(expo.get(expo.size() - 1));
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc ArrayList<Integer> expo = new ArrayList<>(); expo new ArrayList<>() for (int b = 1; b <= 1000; b++) {
      int tmp = b;
      for (int p = 2; p <= 9; p++) {
        tmp *= b;
        if (tmp <= x) {
          expo.add(tmp);
        }
      }
    } int b = 1; int b = 1; b 1 b <= 1000 b 1000 b++ b++ b {
      int tmp = b;
      for (int p = 2; p <= 9; p++) {
        tmp *= b;
        if (tmp <= x) {
          expo.add(tmp);
        }
      }
    } {
      int tmp = b;
      for (int p = 2; p <= 9; p++) {
        tmp *= b;
        if (tmp <= x) {
          expo.add(tmp);
        }
      }
    } int tmp = b; tmp b for (int p = 2; p <= 9; p++) {
        tmp *= b;
        if (tmp <= x) {
          expo.add(tmp);
        }
      } int p = 2; int p = 2; p 2 p <= 9 p 9 p++ p++ p {
        tmp *= b;
        if (tmp <= x) {
          expo.add(tmp);
        }
      } {
        tmp *= b;
        if (tmp <= x) {
          expo.add(tmp);
        }
      } tmp *= b tmp b if (tmp <= x) {
          expo.add(tmp);
        } tmp <= x tmp x {
          expo.add(tmp);
        } expo.add(tmp) expo.add expo tmp Collections.sort(expo) Collections.sort Collections expo System.out.println(expo.get(expo.size() - 1)) System.out.println System.out System System.out expo.get(expo.size() - 1) expo.get expo expo.size() - 1 expo.size() expo.size expo 1 String[] args args public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    ArrayList<Integer> expo = new ArrayList<>();
    for (int b = 1; b <= 1000; b++) {
      int tmp = b;
      for (int p = 2; p <= 9; p++) {
        tmp *= b;
        if (tmp <= x) {
          expo.add(tmp);
        }
      }
    }
    Collections.sort(expo);
    System.out.println(expo.get(expo.size() - 1));
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    ArrayList<Integer> expo = new ArrayList<>();
    for (int b = 1; b <= 1000; b++) {
      int tmp = b;
      for (int p = 2; p <= 9; p++) {
        tmp *= b;
        if (tmp <= x) {
          expo.add(tmp);
        }
      }
    }
    Collections.sort(expo);
    System.out.println(expo.get(expo.size() - 1));
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    ArrayList<Integer> expo = new ArrayList<>();
    for (int b = 1; b <= 1000; b++) {
      int tmp = b;
      for (int p = 2; p <= 9; p++) {
        tmp *= b;
        if (tmp <= x) {
          expo.add(tmp);
        }
      }
    }
    Collections.sort(expo);
    System.out.println(expo.get(expo.size() - 1));
  }
}