import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
      int[]po=new int[]{1,4,8,16,32,64,128,256,512,9,27,81,243,729,25,125,100,625,36,216,49,343,1000,121,144,169,196,225,289,324,361,400,441,484,529,576,676,784,841,900,961,1001};
		Arrays.sort(po);
      int n=sc.nextInt();
      int i=0;
      for(i=0;po[i]<=n;i++){}
      System.out.println(po[i-1]);
    }
}

/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