import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    boolean[] b = new boolean[1001];
    b[1] = true;
    for (int i = 2; i <= 32; i++) {
      int tmp = i * i;
      while (tmp <= 1000) {
        b[tmp] = true;
        tmp *= i;
      }
    }

    int x = sc.nextInt();
    int i = x;
    while (true) {
      if (b[i]) {
        System.out.println(i);
        return;
      }
      i--;
    }

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

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    boolean[] b = new boolean[1001];
    b[1] = true;
    for (int i = 2; i <= 32; i++) {
      int tmp = i * i;
      while (tmp <= 1000) {
        b[tmp] = true;
        tmp *= i;
      }
    }

    int x = sc.nextInt();
    int i = x;
    while (true) {
      if (b[i]) {
        System.out.println(i);
        return;
      }
      i--;
    }

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

    Scanner sc = new Scanner(System.in);
    boolean[] b = new boolean[1001];
    b[1] = true;
    for (int i = 2; i <= 32; i++) {
      int tmp = i * i;
      while (tmp <= 1000) {
        b[tmp] = true;
        tmp *= i;
      }
    }

    int x = sc.nextInt();
    int i = x;
    while (true) {
      if (b[i]) {
        System.out.println(i);
        return;
      }
      i--;
    }

  } main {

    Scanner sc = new Scanner(System.in);
    boolean[] b = new boolean[1001];
    b[1] = true;
    for (int i = 2; i <= 32; i++) {
      int tmp = i * i;
      while (tmp <= 1000) {
        b[tmp] = true;
        tmp *= i;
      }
    }

    int x = sc.nextInt();
    int i = x;
    while (true) {
      if (b[i]) {
        System.out.println(i);
        return;
      }
      i--;
    }

  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) boolean[] b = new boolean[1001]; b new boolean[1001] 1001 b[1] = true b[1] b 1 true for (int i = 2; i <= 32; i++) {
      int tmp = i * i;
      while (tmp <= 1000) {
        b[tmp] = true;
        tmp *= i;
      }
    } int i = 2; int i = 2; i 2 i <= 32 i 32 i++ i++ i {
      int tmp = i * i;
      while (tmp <= 1000) {
        b[tmp] = true;
        tmp *= i;
      }
    } {
      int tmp = i * i;
      while (tmp <= 1000) {
        b[tmp] = true;
        tmp *= i;
      }
    } int tmp = i * i; tmp i * i i i while (tmp <= 1000) {
        b[tmp] = true;
        tmp *= i;
      } tmp <= 1000 tmp 1000 {
        b[tmp] = true;
        tmp *= i;
      } b[tmp] = true b[tmp] b tmp true tmp *= i tmp i int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int i = x; i x while (true) {
      if (b[i]) {
        System.out.println(i);
        return;
      }
      i--;
    } true {
      if (b[i]) {
        System.out.println(i);
        return;
      }
      i--;
    } if (b[i]) {
        System.out.println(i);
        return;
      } b[i] b i {
        System.out.println(i);
        return;
      } System.out.println(i) System.out.println System.out System System.out i return; i-- i String[] args args public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    boolean[] b = new boolean[1001];
    b[1] = true;
    for (int i = 2; i <= 32; i++) {
      int tmp = i * i;
      while (tmp <= 1000) {
        b[tmp] = true;
        tmp *= i;
      }
    }

    int x = sc.nextInt();
    int i = x;
    while (true) {
      if (b[i]) {
        System.out.println(i);
        return;
      }
      i--;
    }

  }
} public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    boolean[] b = new boolean[1001];
    b[1] = true;
    for (int i = 2; i <= 32; i++) {
      int tmp = i * i;
      while (tmp <= 1000) {
        b[tmp] = true;
        tmp *= i;
      }
    }

    int x = sc.nextInt();
    int i = x;
    while (true) {
      if (b[i]) {
        System.out.println(i);
        return;
      }
      i--;
    }

  }
} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    boolean[] b = new boolean[1001];
    b[1] = true;
    for (int i = 2; i <= 32; i++) {
      int tmp = i * i;
      while (tmp <= 1000) {
        b[tmp] = true;
        tmp *= i;
      }
    }

    int x = sc.nextInt();
    int i = x;
    while (true) {
      if (b[i]) {
        System.out.println(i);
        return;
      }
      i--;
    }

  }
}