
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int X = scanner.nextInt();

    if ( X == 1 ) {
      System.out.println(1);
      System.exit(0);
    }

    int max = 0;
    for (int i = 2; i <= X; i++) {
      for ( int j = 2; j <= 1000; j++ ) {
          int b = (int)Math.pow((int)i, (int)j);
          if ( b > X) {
            break;
          }
          if ( b > max ) {
            max = b;
          }
      }
    }
    System.out.println(max);
  }

} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int X = scanner.nextInt();

    if ( X == 1 ) {
      System.out.println(1);
      System.exit(0);
    }

    int max = 0;
    for (int i = 2; i <= X; i++) {
      for ( int j = 2; j <= 1000; j++ ) {
          int b = (int)Math.pow((int)i, (int)j);
          if ( b > X) {
            break;
          }
          if ( b > max ) {
            max = b;
          }
      }
    }
    System.out.println(max);
  }

} Main public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int X = scanner.nextInt();

    if ( X == 1 ) {
      System.out.println(1);
      System.exit(0);
    }

    int max = 0;
    for (int i = 2; i <= X; i++) {
      for ( int j = 2; j <= 1000; j++ ) {
          int b = (int)Math.pow((int)i, (int)j);
          if ( b > X) {
            break;
          }
          if ( b > max ) {
            max = b;
          }
      }
    }
    System.out.println(max);
  } main {
    Scanner scanner = new Scanner(System.in);

    int X = scanner.nextInt();

    if ( X == 1 ) {
      System.out.println(1);
      System.exit(0);
    }

    int max = 0;
    for (int i = 2; i <= X; i++) {
      for ( int j = 2; j <= 1000; j++ ) {
          int b = (int)Math.pow((int)i, (int)j);
          if ( b > X) {
            break;
          }
          if ( b > max ) {
            max = b;
          }
      }
    }
    System.out.println(max);
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int X = scanner.nextInt(); X scanner.nextInt() scanner.nextInt scanner if ( X == 1 ) {
      System.out.println(1);
      System.exit(0);
    } X == 1 X 1 {
      System.out.println(1);
      System.exit(0);
    } System.out.println(1) System.out.println System.out System System.out 1 System.exit(0) System.exit System 0 int max = 0; max 0 for (int i = 2; i <= X; i++) {
      for ( int j = 2; j <= 1000; j++ ) {
          int b = (int)Math.pow((int)i, (int)j);
          if ( b > X) {
            break;
          }
          if ( b > max ) {
            max = b;
          }
      }
    } int i = 2; int i = 2; i 2 i <= X i X i++ i++ i {
      for ( int j = 2; j <= 1000; j++ ) {
          int b = (int)Math.pow((int)i, (int)j);
          if ( b > X) {
            break;
          }
          if ( b > max ) {
            max = b;
          }
      }
    } {
      for ( int j = 2; j <= 1000; j++ ) {
          int b = (int)Math.pow((int)i, (int)j);
          if ( b > X) {
            break;
          }
          if ( b > max ) {
            max = b;
          }
      }
    } for ( int j = 2; j <= 1000; j++ ) {
          int b = (int)Math.pow((int)i, (int)j);
          if ( b > X) {
            break;
          }
          if ( b > max ) {
            max = b;
          }
      } int j = 2; int j = 2; j 2 j <= 1000 j 1000 j++ j++ j {
          int b = (int)Math.pow((int)i, (int)j);
          if ( b > X) {
            break;
          }
          if ( b > max ) {
            max = b;
          }
      } {
          int b = (int)Math.pow((int)i, (int)j);
          if ( b > X) {
            break;
          }
          if ( b > max ) {
            max = b;
          }
      } int b = (int)Math.pow((int)i, (int)j); b (int)Math.pow((int)i, (int)j) Math.pow Math (int)i (int)j if ( b > X) {
            break;
          } b > X b X {
            break;
          } break; if ( b > max ) {
            max = b;
          } b > max b max {
            max = b;
          } max = b max b 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 scanner = new Scanner(System.in);

    int X = scanner.nextInt();

    if ( X == 1 ) {
      System.out.println(1);
      System.exit(0);
    }

    int max = 0;
    for (int i = 2; i <= X; i++) {
      for ( int j = 2; j <= 1000; j++ ) {
          int b = (int)Math.pow((int)i, (int)j);
          if ( b > X) {
            break;
          }
          if ( b > max ) {
            max = b;
          }
      }
    }
    System.out.println(max);
  }

} public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int X = scanner.nextInt();

    if ( X == 1 ) {
      System.out.println(1);
      System.exit(0);
    }

    int max = 0;
    for (int i = 2; i <= X; i++) {
      for ( int j = 2; j <= 1000; j++ ) {
          int b = (int)Math.pow((int)i, (int)j);
          if ( b > X) {
            break;
          }
          if ( b > max ) {
            max = b;
          }
      }
    }
    System.out.println(max);
  }

} Main

import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int X = scanner.nextInt();

    if ( X == 1 ) {
      System.out.println(1);
      System.exit(0);
    }

    int max = 0;
    for (int i = 2; i <= X; i++) {
      for ( int j = 2; j <= 1000; j++ ) {
          int b = (int)Math.pow((int)i, (int)j);
          if ( b > X) {
            break;
          }
          if ( b > max ) {
            max = b;
          }
      }
    }
    System.out.println(max);
  }

}
