import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int X = Integer.parseInt(sc.next());

    int ans = 1;

    for (int i = 2; i < 32; i++) {
      int b = i;
      for (int p = 2; p < 10; p++) {
        b *= i;
        if (b <= X) {
          ans = Math.max(ans, b);
        } else {
          break;
        }
      }
    }

    System.out.println(ans);
  }
} import java.util.Scanner; Scanner java.util public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int X = Integer.parseInt(sc.next());

    int ans = 1;

    for (int i = 2; i < 32; i++) {
      int b = i;
      for (int p = 2; p < 10; p++) {
        b *= i;
        if (b <= X) {
          ans = Math.max(ans, b);
        } else {
          break;
        }
      }
    }

    System.out.println(ans);
  }
} Main public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int X = Integer.parseInt(sc.next());

    int ans = 1;

    for (int i = 2; i < 32; i++) {
      int b = i;
      for (int p = 2; p < 10; p++) {
        b *= i;
        if (b <= X) {
          ans = Math.max(ans, b);
        } else {
          break;
        }
      }
    }

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

    Scanner sc = new Scanner(System.in);

    int X = Integer.parseInt(sc.next());

    int ans = 1;

    for (int i = 2; i < 32; i++) {
      int b = i;
      for (int p = 2; p < 10; p++) {
        b *= i;
        if (b <= X) {
          ans = Math.max(ans, b);
        } else {
          break;
        }
      }
    }

    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = Integer.parseInt(sc.next()); X Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int ans = 1; ans 1 for (int i = 2; i < 32; i++) {
      int b = i;
      for (int p = 2; p < 10; p++) {
        b *= i;
        if (b <= X) {
          ans = Math.max(ans, b);
        } else {
          break;
        }
      }
    } int i = 2; int i = 2; i 2 i < 32 i 32 i++ i++ i {
      int b = i;
      for (int p = 2; p < 10; p++) {
        b *= i;
        if (b <= X) {
          ans = Math.max(ans, b);
        } else {
          break;
        }
      }
    } {
      int b = i;
      for (int p = 2; p < 10; p++) {
        b *= i;
        if (b <= X) {
          ans = Math.max(ans, b);
        } else {
          break;
        }
      }
    } int b = i; b i for (int p = 2; p < 10; p++) {
        b *= i;
        if (b <= X) {
          ans = Math.max(ans, b);
        } else {
          break;
        }
      } int p = 2; int p = 2; p 2 p < 10 p 10 p++ p++ p {
        b *= i;
        if (b <= X) {
          ans = Math.max(ans, b);
        } else {
          break;
        }
      } {
        b *= i;
        if (b <= X) {
          ans = Math.max(ans, b);
        } else {
          break;
        }
      } b *= i b i if (b <= X) {
          ans = Math.max(ans, b);
        } else {
          break;
        } b <= X b X {
          ans = Math.max(ans, b);
        } ans = Math.max(ans, b) ans Math.max(ans, b) Math.max Math ans b {
          break;
        } break; System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int X = Integer.parseInt(sc.next());

    int ans = 1;

    for (int i = 2; i < 32; i++) {
      int b = i;
      for (int p = 2; p < 10; p++) {
        b *= i;
        if (b <= X) {
          ans = Math.max(ans, b);
        } else {
          break;
        }
      }
    }

    System.out.println(ans);
  }
} public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int X = Integer.parseInt(sc.next());

    int ans = 1;

    for (int i = 2; i < 32; i++) {
      int b = i;
      for (int p = 2; p < 10; p++) {
        b *= i;
        if (b <= X) {
          ans = Math.max(ans, b);
        } else {
          break;
        }
      }
    }

    System.out.println(ans);
  }
} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int X = Integer.parseInt(sc.next());

    int ans = 1;

    for (int i = 2; i < 32; i++) {
      int b = i;
      for (int p = 2; p < 10; p++) {
        b *= i;
        if (b <= X) {
          ans = Math.max(ans, b);
        } else {
          break;
        }
      }
    }

    System.out.println(ans);
  }
}