import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
 
   Integer[] beki = new Integer[43];
   for(int i=1;i<=31;i++) beki[i-1]=i*i;
   for(int i=2;i<=10;i++) beki[i+29]=i*i*i;
   for(int i=2;i<=3;i++) beki[i+38]=i*i*i*i*i;
   beki[42]=128;
   
   for(int i=N;true;i--)
   {
     if(Arrays.asList(beki).contains(i))
     {
       System.out.println(i);
       break;
     }
   }
 }
} import java.util.*; util.* java public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
 
   Integer[] beki = new Integer[43];
   for(int i=1;i<=31;i++) beki[i-1]=i*i;
   for(int i=2;i<=10;i++) beki[i+29]=i*i*i;
   for(int i=2;i<=3;i++) beki[i+38]=i*i*i*i*i;
   beki[42]=128;
   
   for(int i=N;true;i--)
   {
     if(Arrays.asList(beki).contains(i))
     {
       System.out.println(i);
       break;
     }
   }
 }
} Main public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
 
   Integer[] beki = new Integer[43];
   for(int i=1;i<=31;i++) beki[i-1]=i*i;
   for(int i=2;i<=10;i++) beki[i+29]=i*i*i;
   for(int i=2;i<=3;i++) beki[i+38]=i*i*i*i*i;
   beki[42]=128;
   
   for(int i=N;true;i--)
   {
     if(Arrays.asList(beki).contains(i))
     {
       System.out.println(i);
       break;
     }
   }
 } main {
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
 
   Integer[] beki = new Integer[43];
   for(int i=1;i<=31;i++) beki[i-1]=i*i;
   for(int i=2;i<=10;i++) beki[i+29]=i*i*i;
   for(int i=2;i<=3;i++) beki[i+38]=i*i*i*i*i;
   beki[42]=128;
   
   for(int i=N;true;i--)
   {
     if(Arrays.asList(beki).contains(i))
     {
       System.out.println(i);
       break;
     }
   }
 } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc Integer[] beki = new Integer[43]; beki new Integer[43] 43 for(int i=1;i<=31;i++) beki[i-1]=i*i; int i=1; int i=1; i 1 i<=31 i 31 i++ i++ i beki[i-1]=i*i; beki[i-1]=i*i beki[i-1] beki i-1 i 1 i*i i i for(int i=2;i<=10;i++) beki[i+29]=i*i*i; int i=2; int i=2; i 2 i<=10 i 10 i++ i++ i beki[i+29]=i*i*i; beki[i+29]=i*i*i beki[i+29] beki i+29 i 29 i*i*i i*i*i i i i for(int i=2;i<=3;i++) beki[i+38]=i*i*i*i*i; int i=2; int i=2; i 2 i<=3 i 3 i++ i++ i beki[i+38]=i*i*i*i*i; beki[i+38]=i*i*i*i*i beki[i+38] beki i+38 i 38 i*i*i*i*i i i i*i*i*i*i i i i i i beki[42]=128 beki[42] beki 42 128 for(int i=N;true;i--)
   {
     if(Arrays.asList(beki).contains(i))
     {
       System.out.println(i);
       break;
     }
   } int i=N; int i=N; i N true i-- i-- i {
     if(Arrays.asList(beki).contains(i))
     {
       System.out.println(i);
       break;
     }
   } {
     if(Arrays.asList(beki).contains(i))
     {
       System.out.println(i);
       break;
     }
   } if(Arrays.asList(beki).contains(i))
     {
       System.out.println(i);
       break;
     } Arrays.asList(beki).contains(i) Arrays.asList(beki).contains Arrays.asList(beki) Arrays.asList Arrays beki i {
       System.out.println(i);
       break;
     } System.out.println(i) System.out.println System.out System System.out i break; String[] args args public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
 
   Integer[] beki = new Integer[43];
   for(int i=1;i<=31;i++) beki[i-1]=i*i;
   for(int i=2;i<=10;i++) beki[i+29]=i*i*i;
   for(int i=2;i<=3;i++) beki[i+38]=i*i*i*i*i;
   beki[42]=128;
   
   for(int i=N;true;i--)
   {
     if(Arrays.asList(beki).contains(i))
     {
       System.out.println(i);
       break;
     }
   }
 }
} public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
 
   Integer[] beki = new Integer[43];
   for(int i=1;i<=31;i++) beki[i-1]=i*i;
   for(int i=2;i<=10;i++) beki[i+29]=i*i*i;
   for(int i=2;i<=3;i++) beki[i+38]=i*i*i*i*i;
   beki[42]=128;
   
   for(int i=N;true;i--)
   {
     if(Arrays.asList(beki).contains(i))
     {
       System.out.println(i);
       break;
     }
   }
 }
} Main
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   int N = sc.nextInt();
 
   Integer[] beki = new Integer[43];
   for(int i=1;i<=31;i++) beki[i-1]=i*i;
   for(int i=2;i<=10;i++) beki[i+29]=i*i*i;
   for(int i=2;i<=3;i++) beki[i+38]=i*i*i*i*i;
   beki[42]=128;
   
   for(int i=N;true;i--)
   {
     if(Arrays.asList(beki).contains(i))
     {
       System.out.println(i);
       break;
     }
   }
 }
}