import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int k = 1;
    int max = 1;

    for (int i = 1; i < x; i++) {
      for (int j = 2; j < x; j++) {
        k = (int)Math.pow(i,j);
        if (k <= x) {
          max = Math.max(max,k);
        }
      }
    }

    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();
    int k = 1;
    int max = 1;

    for (int i = 1; i < x; i++) {
      for (int j = 2; j < x; j++) {
        k = (int)Math.pow(i,j);
        if (k <= x) {
          max = Math.max(max,k);
        }
      }
    }

    System.out.println(max);

  }

} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int k = 1;
    int max = 1;

    for (int i = 1; i < x; i++) {
      for (int j = 2; j < x; j++) {
        k = (int)Math.pow(i,j);
        if (k <= x) {
          max = Math.max(max,k);
        }
      }
    }

    System.out.println(max);

  } main {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int k = 1;
    int max = 1;

    for (int i = 1; i < x; i++) {
      for (int j = 2; j < x; j++) {
        k = (int)Math.pow(i,j);
        if (k <= x) {
          max = Math.max(max,k);
        }
      }
    }

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

    for (int i = 1; i < x; i++) {
      for (int j = 2; j < x; j++) {
        k = (int)Math.pow(i,j);
        if (k <= x) {
          max = Math.max(max,k);
        }
      }
    }

    System.out.println(max);

  }

} public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int k = 1;
    int max = 1;

    for (int i = 1; i < x; i++) {
      for (int j = 2; j < x; j++) {
        k = (int)Math.pow(i,j);
        if (k <= x) {
          max = Math.max(max,k);
        }
      }
    }

    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();
    int k = 1;
    int max = 1;

    for (int i = 1; i < x; i++) {
      for (int j = 2; j < x; j++) {
        k = (int)Math.pow(i,j);
        if (k <= x) {
          max = Math.max(max,k);
        }
      }
    }

    System.out.println(max);

  }

}
