import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int X = sc.nextInt();

    sc.close();

    int max = 1;

    for (int i = 1; i < X; i++) {

      for (int j = 2; j < X; j++) {
        double k = Math.pow(i, j);
        if ((int)k <= X) {
          max = Math.max(max, (int)k);
        } else {
          break;
        }
      }

    }
    
    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();

    sc.close();

    int max = 1;

    for (int i = 1; i < X; i++) {

      for (int j = 2; j < X; j++) {
        double k = Math.pow(i, j);
        if ((int)k <= X) {
          max = Math.max(max, (int)k);
        } else {
          break;
        }
      }

    }
    
    System.out.println(max);
    
  }

} Main public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int X = sc.nextInt();

    sc.close();

    int max = 1;

    for (int i = 1; i < X; i++) {

      for (int j = 2; j < X; j++) {
        double k = Math.pow(i, j);
        if ((int)k <= X) {
          max = Math.max(max, (int)k);
        } else {
          break;
        }
      }

    }
    
    System.out.println(max);
    
  } main {

    Scanner sc = new Scanner(System.in);
    
    int X = sc.nextInt();

    sc.close();

    int max = 1;

    for (int i = 1; i < X; i++) {

      for (int j = 2; j < X; j++) {
        double k = Math.pow(i, j);
        if ((int)k <= X) {
          max = Math.max(max, (int)k);
        } else {
          break;
        }
      }

    }
    
    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 sc.close() sc.close sc int max = 1; max 1 for (int i = 1; i < X; i++) {

      for (int j = 2; j < X; j++) {
        double k = Math.pow(i, j);
        if ((int)k <= X) {
          max = Math.max(max, (int)k);
        } else {
          break;
        }
      }

    } int i = 1; int i = 1; i 1 i < X i X i++ i++ i {

      for (int j = 2; j < X; j++) {
        double k = Math.pow(i, j);
        if ((int)k <= X) {
          max = Math.max(max, (int)k);
        } else {
          break;
        }
      }

    } {

      for (int j = 2; j < X; j++) {
        double k = Math.pow(i, j);
        if ((int)k <= X) {
          max = Math.max(max, (int)k);
        } else {
          break;
        }
      }

    } for (int j = 2; j < X; j++) {
        double k = Math.pow(i, j);
        if ((int)k <= X) {
          max = Math.max(max, (int)k);
        } else {
          break;
        }
      } int j = 2; int j = 2; j 2 j < X j X j++ j++ j {
        double k = Math.pow(i, j);
        if ((int)k <= X) {
          max = Math.max(max, (int)k);
        } else {
          break;
        }
      } {
        double k = Math.pow(i, j);
        if ((int)k <= X) {
          max = Math.max(max, (int)k);
        } else {
          break;
        }
      } double k = Math.pow(i, j); k Math.pow(i, j) Math.pow Math i j if ((int)k <= X) {
          max = Math.max(max, (int)k);
        } else {
          break;
        } (int)k <= X (int)k X {
          max = Math.max(max, (int)k);
        } max = Math.max(max, (int)k) max Math.max(max, (int)k) Math.max Math max (int)k {
          break;
        } break; 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();

    sc.close();

    int max = 1;

    for (int i = 1; i < X; i++) {

      for (int j = 2; j < X; j++) {
        double k = Math.pow(i, j);
        if ((int)k <= X) {
          max = Math.max(max, (int)k);
        } else {
          break;
        }
      }

    }
    
    System.out.println(max);
    
  }

} public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int X = sc.nextInt();

    sc.close();

    int max = 1;

    for (int i = 1; i < X; i++) {

      for (int j = 2; j < X; j++) {
        double k = Math.pow(i, j);
        if ((int)k <= X) {
          max = Math.max(max, (int)k);
        } else {
          break;
        }
      }

    }
    
    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();

    sc.close();

    int max = 1;

    for (int i = 1; i < X; i++) {

      for (int j = 2; j < X; j++) {
        double k = Math.pow(i, j);
        if ((int)k <= X) {
          max = Math.max(max, (int)k);
        } else {
          break;
        }
      }

    }
    
    System.out.println(max);
    
  }

}