import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int Max = 0;

    for(int b = 1; b <= Math.sqrt(x); b++){
      int max = 0;
      int p = 2;
      while(Math.pow((double)b, (double)p) <= x){
        if(b == 1){max = 1; break;}
        max = (int)Math.pow((double)b, (double)p);
        p++;
      }
      Max = Math.max(Max, max);
    }

    System.out.println(Max);

  }
}

/*

int n = sc.nextInt();
String blank = sc.nextLine();
String s = sc.nextLine();
System.out.println();
System.exit(0)
*/ 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 Max = 0;

    for(int b = 1; b <= Math.sqrt(x); b++){
      int max = 0;
      int p = 2;
      while(Math.pow((double)b, (double)p) <= x){
        if(b == 1){max = 1; break;}
        max = (int)Math.pow((double)b, (double)p);
        p++;
      }
      Max = Math.max(Max, max);
    }

    System.out.println(Max);

  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int Max = 0;

    for(int b = 1; b <= Math.sqrt(x); b++){
      int max = 0;
      int p = 2;
      while(Math.pow((double)b, (double)p) <= x){
        if(b == 1){max = 1; break;}
        max = (int)Math.pow((double)b, (double)p);
        p++;
      }
      Max = Math.max(Max, max);
    }

    System.out.println(Max);

  } main {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int Max = 0;

    for(int b = 1; b <= Math.sqrt(x); b++){
      int max = 0;
      int p = 2;
      while(Math.pow((double)b, (double)p) <= x){
        if(b == 1){max = 1; break;}
        max = (int)Math.pow((double)b, (double)p);
        p++;
      }
      Max = Math.max(Max, max);
    }

    System.out.println(Max);

  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int Max = 0; Max 0 for(int b = 1; b <= Math.sqrt(x); b++){
      int max = 0;
      int p = 2;
      while(Math.pow((double)b, (double)p) <= x){
        if(b == 1){max = 1; break;}
        max = (int)Math.pow((double)b, (double)p);
        p++;
      }
      Max = Math.max(Max, max);
    } int b = 1; int b = 1; b 1 b <= Math.sqrt(x) b Math.sqrt(x) Math.sqrt Math x b++ b++ b {
      int max = 0;
      int p = 2;
      while(Math.pow((double)b, (double)p) <= x){
        if(b == 1){max = 1; break;}
        max = (int)Math.pow((double)b, (double)p);
        p++;
      }
      Max = Math.max(Max, max);
    } {
      int max = 0;
      int p = 2;
      while(Math.pow((double)b, (double)p) <= x){
        if(b == 1){max = 1; break;}
        max = (int)Math.pow((double)b, (double)p);
        p++;
      }
      Max = Math.max(Max, max);
    } int max = 0; max 0 int p = 2; p 2 while(Math.pow((double)b, (double)p) <= x){
        if(b == 1){max = 1; break;}
        max = (int)Math.pow((double)b, (double)p);
        p++;
      } Math.pow((double)b, (double)p) <= x Math.pow((double)b, (double)p) Math.pow Math (double)b (double)p x {
        if(b == 1){max = 1; break;}
        max = (int)Math.pow((double)b, (double)p);
        p++;
      } if(b == 1){max = 1; break;} b == 1 b 1 {max = 1; break;} max = 1 max 1 break; max = (int)Math.pow((double)b, (double)p) max (int)Math.pow((double)b, (double)p) Math.pow Math (double)b (double)p p++ p Max = Math.max(Max, max) Max Math.max(Max, max) Math.max Math Max max System.out.println(Max) System.out.println System.out System System.out Max String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int Max = 0;

    for(int b = 1; b <= Math.sqrt(x); b++){
      int max = 0;
      int p = 2;
      while(Math.pow((double)b, (double)p) <= x){
        if(b == 1){max = 1; break;}
        max = (int)Math.pow((double)b, (double)p);
        p++;
      }
      Max = Math.max(Max, max);
    }

    System.out.println(Max);

  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int Max = 0;

    for(int b = 1; b <= Math.sqrt(x); b++){
      int max = 0;
      int p = 2;
      while(Math.pow((double)b, (double)p) <= x){
        if(b == 1){max = 1; break;}
        max = (int)Math.pow((double)b, (double)p);
        p++;
      }
      Max = Math.max(Max, max);
    }

    System.out.println(Max);

  }
} Main
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int Max = 0;

    for(int b = 1; b <= Math.sqrt(x); b++){
      int max = 0;
      int p = 2;
      while(Math.pow((double)b, (double)p) <= x){
        if(b == 1){max = 1; break;}
        max = (int)Math.pow((double)b, (double)p);
        p++;
      }
      Max = Math.max(Max, max);
    }

    System.out.println(Max);

  }
}

/*

int n = sc.nextInt();
String blank = sc.nextLine();
String s = sc.nextLine();
System.out.println();
System.exit(0)
*/
