#include<bits/stdc++.h>
using namespace std;
int main(void){

  int X; cin >> X;
  int max = 1;
  for(int i = 2 ; i < X / 2 ; i++){
    int a = i;
    while(a <= X)  a *=i;
    a /= i;
    max = (max < a)? a : max;
  }

  printf("%d\n", max);

return 0;
}