import java.util.*;
import java.lang.Math;
public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int X = sc.nextInt();
      int Y = 0;
      int[] x2 = new int[50];
      for(int i=0;i<32;i++){
        x2[i]=i*i;
        if(Y<x2[i]&&x2[i]<=X){
        	Y=x2[i];
        }
      }
      for(int j=0;j<11;j++){
      	x2[j+31]=j*j*j;
        if(Y<x2[j]&&x2[j]<=X){
        	Y=x2[j];
        }
      }
      int[] a = {16,81,256,625,32,243,64,729,128,256,512};
      for(int k=0;k<11;k++){
      	if(Y<a[k]&&a[k]<=X){
        	Y=a[k];
        }
      }
          if(X==1000){System.out.println(1000);}else{System.out.println(Y);}
    }
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz