import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int X = s.nextInt();
    int ans = solve(X);
    System.out.println(ans);
  }

  public static int solve(int X){
    int ans = 0;
    for(int b = 1; b <= 32 ; b++){
      for(int p = 2; p <= 32 ; p++){
        if(Math.pow(b,p) > X)break;
        if(ans < Math.pow(b,p)){
          ans = (int)Math.pow(b,p);
        }
      }
    }
    return ans;
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int X = s.nextInt();
    int ans = solve(X);
    System.out.println(ans);
  }

  public static int solve(int X){
    int ans = 0;
    for(int b = 1; b <= 32 ; b++){
      for(int p = 2; p <= 32 ; p++){
        if(Math.pow(b,p) > X)break;
        if(ans < Math.pow(b,p)){
          ans = (int)Math.pow(b,p);
        }
      }
    }
    return ans;
  }
} Main public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int X = s.nextInt();
    int ans = solve(X);
    System.out.println(ans);
  } main {
    Scanner s = new Scanner(System.in);
    int X = s.nextInt();
    int ans = solve(X);
    System.out.println(ans);
  } Scanner s = new Scanner(System.in); s new Scanner(System.in) int X = s.nextInt(); X s.nextInt() s.nextInt s int ans = solve(X); ans solve(X) solve X System.out.println(ans) System.out.println System.out System System.out ans String[] args args public static int solve(int X){
    int ans = 0;
    for(int b = 1; b <= 32 ; b++){
      for(int p = 2; p <= 32 ; p++){
        if(Math.pow(b,p) > X)break;
        if(ans < Math.pow(b,p)){
          ans = (int)Math.pow(b,p);
        }
      }
    }
    return ans;
  } solve {
    int ans = 0;
    for(int b = 1; b <= 32 ; b++){
      for(int p = 2; p <= 32 ; p++){
        if(Math.pow(b,p) > X)break;
        if(ans < Math.pow(b,p)){
          ans = (int)Math.pow(b,p);
        }
      }
    }
    return ans;
  } int ans = 0; ans 0 for(int b = 1; b <= 32 ; b++){
      for(int p = 2; p <= 32 ; p++){
        if(Math.pow(b,p) > X)break;
        if(ans < Math.pow(b,p)){
          ans = (int)Math.pow(b,p);
        }
      }
    } int b = 1; int b = 1; b 1 b <= 32 b 32 b++ b++ b {
      for(int p = 2; p <= 32 ; p++){
        if(Math.pow(b,p) > X)break;
        if(ans < Math.pow(b,p)){
          ans = (int)Math.pow(b,p);
        }
      }
    } {
      for(int p = 2; p <= 32 ; p++){
        if(Math.pow(b,p) > X)break;
        if(ans < Math.pow(b,p)){
          ans = (int)Math.pow(b,p);
        }
      }
    } for(int p = 2; p <= 32 ; p++){
        if(Math.pow(b,p) > X)break;
        if(ans < Math.pow(b,p)){
          ans = (int)Math.pow(b,p);
        }
      } int p = 2; int p = 2; p 2 p <= 32 p 32 p++ p++ p {
        if(Math.pow(b,p) > X)break;
        if(ans < Math.pow(b,p)){
          ans = (int)Math.pow(b,p);
        }
      } {
        if(Math.pow(b,p) > X)break;
        if(ans < Math.pow(b,p)){
          ans = (int)Math.pow(b,p);
        }
      } if(Math.pow(b,p) > X)break; Math.pow(b,p) > X Math.pow(b,p) Math.pow Math b p X break; if(ans < Math.pow(b,p)){
          ans = (int)Math.pow(b,p);
        } ans < Math.pow(b,p) ans Math.pow(b,p) Math.pow Math b p {
          ans = (int)Math.pow(b,p);
        } ans = (int)Math.pow(b,p) ans (int)Math.pow(b,p) Math.pow Math b p return ans; ans int X X public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int X = s.nextInt();
    int ans = solve(X);
    System.out.println(ans);
  }

  public static int solve(int X){
    int ans = 0;
    for(int b = 1; b <= 32 ; b++){
      for(int p = 2; p <= 32 ; p++){
        if(Math.pow(b,p) > X)break;
        if(ans < Math.pow(b,p)){
          ans = (int)Math.pow(b,p);
        }
      }
    }
    return ans;
  }
} public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int X = s.nextInt();
    int ans = solve(X);
    System.out.println(ans);
  }

  public static int solve(int X){
    int ans = 0;
    for(int b = 1; b <= 32 ; b++){
      for(int p = 2; p <= 32 ; p++){
        if(Math.pow(b,p) > X)break;
        if(ans < Math.pow(b,p)){
          ans = (int)Math.pow(b,p);
        }
      }
    }
    return ans;
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int X = s.nextInt();
    int ans = solve(X);
    System.out.println(ans);
  }

  public static int solve(int X){
    int ans = 0;
    for(int b = 1; b <= 32 ; b++){
      for(int p = 2; p <= 32 ; p++){
        if(Math.pow(b,p) > X)break;
        if(ans < Math.pow(b,p)){
          ans = (int)Math.pow(b,p);
        }
      }
    }
    return ans;
  }
}
