import java.util.*;
public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int x = sc.nextInt();

      int[] n = {1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000, 1001};

     int i = 0; 
     
      for (i = 0; i < 43; i++) {
         if ( x < n[i]) {
            break;
         }
      }

      System.out.println(n[i-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[] n = {1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000, 1001};

     int i = 0; 
     
      for (i = 0; i < 43; i++) {
         if ( x < n[i]) {
            break;
         }
      }

      System.out.println(n[i-1]);
   }
} Main public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int x = sc.nextInt();

      int[] n = {1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000, 1001};

     int i = 0; 
     
      for (i = 0; i < 43; i++) {
         if ( x < n[i]) {
            break;
         }
      }

      System.out.println(n[i-1]);
   } main {
      Scanner sc = new Scanner(System.in);

      int x = sc.nextInt();

      int[] n = {1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000, 1001};

     int i = 0; 
     
      for (i = 0; i < 43; i++) {
         if ( x < n[i]) {
            break;
         }
      }

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

      int x = sc.nextInt();

      int[] n = {1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000, 1001};

     int i = 0; 
     
      for (i = 0; i < 43; i++) {
         if ( x < n[i]) {
            break;
         }
      }

      System.out.println(n[i-1]);
   }
} public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int x = sc.nextInt();

      int[] n = {1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000, 1001};

     int i = 0; 
     
      for (i = 0; i < 43; i++) {
         if ( x < n[i]) {
            break;
         }
      }

      System.out.println(n[i-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[] n = {1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100, 121, 125, 128, 144, 169, 196, 216, 225, 243, 256, 289, 324, 343, 361, 400, 441, 484, 512, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1000, 1001};

     int i = 0; 
     
      for (i = 0; i < 43; i++) {
         if ( x < n[i]) {
            break;
         }
      }

      System.out.println(n[i-1]);
   }
}