import java.util.*;


public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int expMax = 1 ;

    for(int i = 2 ; i <= Math.sqrt(X); i ++){
      int index = 1 ;
      int exp = i;
      int expWork = exp;
      while(expWork <= X){
        if(expMax < expWork){
          expMax = expWork;
        }
        expWork = expWork * exp ;
        index ++ ;
      }
    }

    System.out.println(expMax);
  }
} 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 expMax = 1 ;

    for(int i = 2 ; i <= Math.sqrt(X); i ++){
      int index = 1 ;
      int exp = i;
      int expWork = exp;
      while(expWork <= X){
        if(expMax < expWork){
          expMax = expWork;
        }
        expWork = expWork * exp ;
        index ++ ;
      }
    }

    System.out.println(expMax);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int expMax = 1 ;

    for(int i = 2 ; i <= Math.sqrt(X); i ++){
      int index = 1 ;
      int exp = i;
      int expWork = exp;
      while(expWork <= X){
        if(expMax < expWork){
          expMax = expWork;
        }
        expWork = expWork * exp ;
        index ++ ;
      }
    }

    System.out.println(expMax);
  } main {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int expMax = 1 ;

    for(int i = 2 ; i <= Math.sqrt(X); i ++){
      int index = 1 ;
      int exp = i;
      int expWork = exp;
      while(expWork <= X){
        if(expMax < expWork){
          expMax = expWork;
        }
        expWork = expWork * exp ;
        index ++ ;
      }
    }

    System.out.println(expMax);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc int expMax = 1 ; expMax 1 for(int i = 2 ; i <= Math.sqrt(X); i ++){
      int index = 1 ;
      int exp = i;
      int expWork = exp;
      while(expWork <= X){
        if(expMax < expWork){
          expMax = expWork;
        }
        expWork = expWork * exp ;
        index ++ ;
      }
    } int i = 2 ; int i = 2 ; i 2 i <= Math.sqrt(X) i Math.sqrt(X) Math.sqrt Math X i ++ i ++ i {
      int index = 1 ;
      int exp = i;
      int expWork = exp;
      while(expWork <= X){
        if(expMax < expWork){
          expMax = expWork;
        }
        expWork = expWork * exp ;
        index ++ ;
      }
    } {
      int index = 1 ;
      int exp = i;
      int expWork = exp;
      while(expWork <= X){
        if(expMax < expWork){
          expMax = expWork;
        }
        expWork = expWork * exp ;
        index ++ ;
      }
    } int index = 1 ; index 1 int exp = i; exp i int expWork = exp; expWork exp while(expWork <= X){
        if(expMax < expWork){
          expMax = expWork;
        }
        expWork = expWork * exp ;
        index ++ ;
      } expWork <= X expWork X {
        if(expMax < expWork){
          expMax = expWork;
        }
        expWork = expWork * exp ;
        index ++ ;
      } if(expMax < expWork){
          expMax = expWork;
        } expMax < expWork expMax expWork {
          expMax = expWork;
        } expMax = expWork expMax expWork expWork = expWork * exp expWork expWork * exp expWork exp index ++ index System.out.println(expMax) System.out.println System.out System System.out expMax String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int expMax = 1 ;

    for(int i = 2 ; i <= Math.sqrt(X); i ++){
      int index = 1 ;
      int exp = i;
      int expWork = exp;
      while(expWork <= X){
        if(expMax < expWork){
          expMax = expWork;
        }
        expWork = expWork * exp ;
        index ++ ;
      }
    }

    System.out.println(expMax);
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int expMax = 1 ;

    for(int i = 2 ; i <= Math.sqrt(X); i ++){
      int index = 1 ;
      int exp = i;
      int expWork = exp;
      while(expWork <= X){
        if(expMax < expWork){
          expMax = expWork;
        }
        expWork = expWork * exp ;
        index ++ ;
      }
    }

    System.out.println(expMax);
  }
} Main
import java.util.*;


public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int expMax = 1 ;

    for(int i = 2 ; i <= Math.sqrt(X); i ++){
      int index = 1 ;
      int exp = i;
      int expWork = exp;
      while(expWork <= X){
        if(expMax < expWork){
          expMax = expWork;
        }
        expWork = expWork * exp ;
        index ++ ;
      }
    }

    System.out.println(expMax);
  }
}
