import java.util.*;

public class Main{
  
  public static void main (String []args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    if (N == 1) { 
      System.out.println(1); return; 
    }
    
    int max = Integer.MIN_VALUE;
    for (int i = 2; i <= N; i++) {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) {
          break;
        }
        max = Math.max((int)pow, max);
      }
    }
    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 N = sc.nextInt();
    
    if (N == 1) { 
      System.out.println(1); return; 
    }
    
    int max = Integer.MIN_VALUE;
    for (int i = 2; i <= N; i++) {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) {
          break;
        }
        max = Math.max((int)pow, max);
      }
    }
    System.out.println(max);
  }
} Main public static void main (String []args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    if (N == 1) { 
      System.out.println(1); return; 
    }
    
    int max = Integer.MIN_VALUE;
    for (int i = 2; i <= N; i++) {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) {
          break;
        }
        max = Math.max((int)pow, max);
      }
    }
    System.out.println(max);
  } main {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    if (N == 1) { 
      System.out.println(1); return; 
    }
    
    int max = Integer.MIN_VALUE;
    for (int i = 2; i <= N; i++) {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) {
          break;
        }
        max = Math.max((int)pow, max);
      }
    }
    System.out.println(max);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc if (N == 1) { 
      System.out.println(1); return; 
    } N == 1 N 1 { 
      System.out.println(1); return; 
    } System.out.println(1) System.out.println System.out System System.out 1 return; int max = Integer.MIN_VALUE; max Integer.MIN_VALUE Integer Integer.MIN_VALUE for (int i = 2; i <= N; i++) {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) {
          break;
        }
        max = Math.max((int)pow, max);
      }
    } int i = 2; int i = 2; i 2 i <= N i N i++ i++ i {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) {
          break;
        }
        max = Math.max((int)pow, max);
      }
    } {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) {
          break;
        }
        max = Math.max((int)pow, max);
      }
    } for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) {
          break;
        }
        max = Math.max((int)pow, max);
      } int j = 2; int j = 2; j 2 j <= N j N j++ j++ j {
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) {
          break;
        }
        max = Math.max((int)pow, max);
      } {
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) {
          break;
        }
        max = Math.max((int)pow, max);
      } double pow = Math.pow((double)i, (double)j); pow Math.pow((double)i, (double)j) Math.pow Math (double)i (double)j if (pow > N) {
          break;
        } pow > N pow N {
          break;
        } break; max = Math.max((int)pow, max) max Math.max((int)pow, max) Math.max Math (int)pow max 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 N = sc.nextInt();
    
    if (N == 1) { 
      System.out.println(1); return; 
    }
    
    int max = Integer.MIN_VALUE;
    for (int i = 2; i <= N; i++) {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) {
          break;
        }
        max = Math.max((int)pow, max);
      }
    }
    System.out.println(max);
  }
} public class Main{
  
  public static void main (String []args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    if (N == 1) { 
      System.out.println(1); return; 
    }
    
    int max = Integer.MIN_VALUE;
    for (int i = 2; i <= N; i++) {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) {
          break;
        }
        max = Math.max((int)pow, max);
      }
    }
    System.out.println(max);
  }
} Main
import java.util.*;

public class Main{
  
  public static void main (String []args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    
    if (N == 1) { 
      System.out.println(1); return; 
    }
    
    int max = Integer.MIN_VALUE;
    for (int i = 2; i <= N; i++) {
      for (int j = 2; j <= N; j++ ){
        double pow = Math.pow((double)i, (double)j);
        if (pow > N) {
          break;
        }
        max = Math.max((int)pow, max);
      }
    }
    System.out.println(max);
  }
}
      