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]);
    }
} import java.util.*; util.* java 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]);
    }
} 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]);
    } main {
        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]);
    } Scanner sc=new Scanner(System.in); 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}; 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) Arrays.sort Arrays po int n=sc.nextInt(); n sc.nextInt() sc.nextInt sc int i=0; i 0 for(i=0;po[i]<=n;i++){} i=0; i=0 i 0 po[i]<=n po[i] po i n i++ i++ i {} {} System.out.println(po[i-1]) System.out.println System.out System System.out po[i-1] po i-1 i 1 String[] args args 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]);
    }
} 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]);
    }
} Main
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]);
    }
}
