import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    boolean[] rui = new boolean[x + 1];
    rui[1] = true;
    for(int b = 2; b <= x; b++) {
      int s = (b * b);
      while(s <= x) {
        rui[s] = true;
        s *= b;
      }
    }
    int ans = 1;
    for(int i = x; i >= 1; i--) {
      if(rui[i]) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    boolean[] rui = new boolean[x + 1];
    rui[1] = true;
    for(int b = 2; b <= x; b++) {
      int s = (b * b);
      while(s <= x) {
        rui[s] = true;
        s *= b;
      }
    }
    int ans = 1;
    for(int i = x; i >= 1; i--) {
      if(rui[i]) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    boolean[] rui = new boolean[x + 1];
    rui[1] = true;
    for(int b = 2; b <= x; b++) {
      int s = (b * b);
      while(s <= x) {
        rui[s] = true;
        s *= b;
      }
    }
    int ans = 1;
    for(int i = x; i >= 1; i--) {
      if(rui[i]) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    boolean[] rui = new boolean[x + 1];
    rui[1] = true;
    for(int b = 2; b <= x; b++) {
      int s = (b * b);
      while(s <= x) {
        rui[s] = true;
        s *= b;
      }
    }
    int ans = 1;
    for(int i = x; i >= 1; i--) {
      if(rui[i]) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc boolean[] rui = new boolean[x + 1]; rui new boolean[x + 1] x + 1 x 1 rui[1] = true rui[1] rui 1 true for(int b = 2; b <= x; b++) {
      int s = (b * b);
      while(s <= x) {
        rui[s] = true;
        s *= b;
      }
    } int b = 2; int b = 2; b 2 b <= x b x b++ b++ b {
      int s = (b * b);
      while(s <= x) {
        rui[s] = true;
        s *= b;
      }
    } {
      int s = (b * b);
      while(s <= x) {
        rui[s] = true;
        s *= b;
      }
    } int s = (b * b); s (b * b) b b while(s <= x) {
        rui[s] = true;
        s *= b;
      } s <= x s x {
        rui[s] = true;
        s *= b;
      } rui[s] = true rui[s] rui s true s *= b s b int ans = 1; ans 1 for(int i = x; i >= 1; i--) {
      if(rui[i]) {
        ans = i;
        break;
      }
    } int i = x; int i = x; i x i >= 1 i 1 i-- i-- i {
      if(rui[i]) {
        ans = i;
        break;
      }
    } {
      if(rui[i]) {
        ans = i;
        break;
      }
    } if(rui[i]) {
        ans = i;
        break;
      } rui[i] rui i {
        ans = i;
        break;
      } ans = i ans i 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 = sc.nextInt();
    boolean[] rui = new boolean[x + 1];
    rui[1] = true;
    for(int b = 2; b <= x; b++) {
      int s = (b * b);
      while(s <= x) {
        rui[s] = true;
        s *= b;
      }
    }
    int ans = 1;
    for(int i = x; i >= 1; i--) {
      if(rui[i]) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    boolean[] rui = new boolean[x + 1];
    rui[1] = true;
    for(int b = 2; b <= x; b++) {
      int s = (b * b);
      while(s <= x) {
        rui[s] = true;
        s *= b;
      }
    }
    int ans = 1;
    for(int i = x; i >= 1; i--) {
      if(rui[i]) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    boolean[] rui = new boolean[x + 1];
    rui[1] = true;
    for(int b = 2; b <= x; b++) {
      int s = (b * b);
      while(s <= x) {
        rui[s] = true;
        s *= b;
      }
    }
    int ans = 1;
    for(int i = x; i >= 1; i--) {
      if(rui[i]) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}
