import java.util.Scanner;
import java.util.stream.Stream;
import java.util.Arrays;

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

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    if (N == 1) { System.out.println(1); return; }

    int max = Integer.MIN_VALUE;
    for (int i = 2; i <= N; i++) {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) break;

        max = Math.max((int)pow, max);
      }
    }
    System.out.println(max);

        // 10の場合
        // 2^2, 2^3, 2^4 > 10
        // 3^2, 3^3 > 10
        // 4^2 > 10
  }
} import java.util.Scanner; Scanner java.util import java.util.stream.Stream; Stream java.util.stream import java.util.Arrays; Arrays java.util public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    if (N == 1) { System.out.println(1); return; }

    int max = Integer.MIN_VALUE;
    for (int i = 2; i <= N; i++) {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) break;

        max = Math.max((int)pow, max);
      }
    }
    System.out.println(max);

        // 10の場合
        // 2^2, 2^3, 2^4 > 10
        // 3^2, 3^3 > 10
        // 4^2 > 10
  }
} Main public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    if (N == 1) { System.out.println(1); return; }

    int max = Integer.MIN_VALUE;
    for (int i = 2; i <= N; i++) {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) break;

        max = Math.max((int)pow, max);
      }
    }
    System.out.println(max);

        // 10の場合
        // 2^2, 2^3, 2^4 > 10
        // 3^2, 3^3 > 10
        // 4^2 > 10
  } main {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    if (N == 1) { System.out.println(1); return; }

    int max = Integer.MIN_VALUE;
    for (int i = 2; i <= N; i++) {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) break;

        max = Math.max((int)pow, max);
      }
    }
    System.out.println(max);

        // 10の場合
        // 2^2, 2^3, 2^4 > 10
        // 3^2, 3^3 > 10
        // 4^2 > 10
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc if (N == 1) { System.out.println(1); return; } N == 1 N 1 { System.out.println(1); return; } System.out.println(1) System.out.println System.out System System.out 1 return; int max = Integer.MIN_VALUE; max Integer.MIN_VALUE Integer Integer.MIN_VALUE for (int i = 2; i <= N; i++) {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) break;

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

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

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

        max = Math.max((int)pow, max);
      } int j = 2; int j = 2; j 2 j <= N j N j++ j++ j {
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) break;

        max = Math.max((int)pow, max);
      } {
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) break;

        max = Math.max((int)pow, max);
      } double pow = Math.pow((double)i, (double)j); pow Math.pow((double)i, (double)j) Math.pow Math (double)i (double)j if (pow > N) break; pow > N pow N break; max = Math.max((int)pow, max) max Math.max((int)pow, max) Math.max Math (int)pow max 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 N = sc.nextInt();
    if (N == 1) { System.out.println(1); return; }

    int max = Integer.MIN_VALUE;
    for (int i = 2; i <= N; i++) {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) break;

        max = Math.max((int)pow, max);
      }
    }
    System.out.println(max);

        // 10の場合
        // 2^2, 2^3, 2^4 > 10
        // 3^2, 3^3 > 10
        // 4^2 > 10
  }
} public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    if (N == 1) { System.out.println(1); return; }

    int max = Integer.MIN_VALUE;
    for (int i = 2; i <= N; i++) {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) break;

        max = Math.max((int)pow, max);
      }
    }
    System.out.println(max);

        // 10の場合
        // 2^2, 2^3, 2^4 > 10
        // 3^2, 3^3 > 10
        // 4^2 > 10
  }
} Main
import java.util.Scanner;
import java.util.stream.Stream;
import java.util.Arrays;

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

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    if (N == 1) { System.out.println(1); return; }

    int max = Integer.MIN_VALUE;
    for (int i = 2; i <= N; i++) {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) break;

        max = Math.max((int)pow, max);
      }
    }
    System.out.println(max);

        // 10の場合
        // 2^2, 2^3, 2^4 > 10
        // 3^2, 3^3 > 10
        // 4^2 > 10
  }
}
