import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();

    int max = 1;
    for (int b = 2; b * b <= X; b++) {
      for (int p = 2; beki(b, p) <= X; p++) {
        int n = beki(b, p);
        if (max < n) {
          max = n;
        }
      }
    }
    System.out.println(max);
  }
  
  private static int beki(int b, int p) {
    if (p == 0) {
      return 1;
    }
    
    return b * beki(b, p-1);
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();

    int max = 1;
    for (int b = 2; b * b <= X; b++) {
      for (int p = 2; beki(b, p) <= X; p++) {
        int n = beki(b, p);
        if (max < n) {
          max = n;
        }
      }
    }
    System.out.println(max);
  }
  
  private static int beki(int b, int p) {
    if (p == 0) {
      return 1;
    }
    
    return b * beki(b, p-1);
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();

    int max = 1;
    for (int b = 2; b * b <= X; b++) {
      for (int p = 2; beki(b, p) <= X; p++) {
        int n = beki(b, p);
        if (max < n) {
          max = n;
        }
      }
    }
    System.out.println(max);
  } main {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();

    int max = 1;
    for (int b = 2; b * b <= X; b++) {
      for (int p = 2; beki(b, p) <= X; p++) {
        int n = beki(b, p);
        if (max < n) {
          max = n;
        }
      }
    }
    System.out.println(max);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc int max = 1; max 1 for (int b = 2; b * b <= X; b++) {
      for (int p = 2; beki(b, p) <= X; p++) {
        int n = beki(b, p);
        if (max < n) {
          max = n;
        }
      }
    } int b = 2; int b = 2; b 2 b * b <= X b * b b b X b++ b++ b {
      for (int p = 2; beki(b, p) <= X; p++) {
        int n = beki(b, p);
        if (max < n) {
          max = n;
        }
      }
    } {
      for (int p = 2; beki(b, p) <= X; p++) {
        int n = beki(b, p);
        if (max < n) {
          max = n;
        }
      }
    } for (int p = 2; beki(b, p) <= X; p++) {
        int n = beki(b, p);
        if (max < n) {
          max = n;
        }
      } int p = 2; int p = 2; p 2 beki(b, p) <= X beki(b, p) beki b p X p++ p++ p {
        int n = beki(b, p);
        if (max < n) {
          max = n;
        }
      } {
        int n = beki(b, p);
        if (max < n) {
          max = n;
        }
      } int n = beki(b, p); n beki(b, p) beki b p if (max < n) {
          max = n;
        } max < n max n {
          max = n;
        } max = n max n System.out.println(max) System.out.println System.out System System.out max String[] args args private static int beki(int b, int p) {
    if (p == 0) {
      return 1;
    }
    
    return b * beki(b, p-1);
  } beki {
    if (p == 0) {
      return 1;
    }
    
    return b * beki(b, p-1);
  } if (p == 0) {
      return 1;
    } p == 0 p 0 {
      return 1;
    } return 1; 1 return b * beki(b, p-1); b * beki(b, p-1) b beki(b, p-1) beki b p-1 p 1 int b b int p p public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();

    int max = 1;
    for (int b = 2; b * b <= X; b++) {
      for (int p = 2; beki(b, p) <= X; p++) {
        int n = beki(b, p);
        if (max < n) {
          max = n;
        }
      }
    }
    System.out.println(max);
  }
  
  private static int beki(int b, int p) {
    if (p == 0) {
      return 1;
    }
    
    return b * beki(b, p-1);
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();

    int max = 1;
    for (int b = 2; b * b <= X; b++) {
      for (int p = 2; beki(b, p) <= X; p++) {
        int n = beki(b, p);
        if (max < n) {
          max = n;
        }
      }
    }
    System.out.println(max);
  }
  
  private static int beki(int b, int p) {
    if (p == 0) {
      return 1;
    }
    
    return b * beki(b, p-1);
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();

    int max = 1;
    for (int b = 2; b * b <= X; b++) {
      for (int p = 2; beki(b, p) <= X; p++) {
        int n = beki(b, p);
        if (max < n) {
          max = n;
        }
      }
    }
    System.out.println(max);
  }
  
  private static int beki(int b, int p) {
    if (p == 0) {
      return 1;
    }
    
    return b * beki(b, p-1);
  }
}