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 i=1; i<= X; i++) {
      for (int j=2; j<= 10; j++) {
        int sum = (int)Math.pow(i,j);
        if (sum <= X) {
          max = Math.max(sum,max);
        }
      }
    }
    System.out.println(max);
  }
} 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 i=1; i<= X; i++) {
      for (int j=2; j<= 10; j++) {
        int sum = (int)Math.pow(i,j);
        if (sum <= X) {
          max = Math.max(sum,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 i=1; i<= X; i++) {
      for (int j=2; j<= 10; j++) {
        int sum = (int)Math.pow(i,j);
        if (sum <= X) {
          max = Math.max(sum,max);
        }
      }
    }
    System.out.println(max);
  } main {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int max =0;
    for (int i=1; i<= X; i++) {
      for (int j=2; j<= 10; j++) {
        int sum = (int)Math.pow(i,j);
        if (sum <= X) {
          max = Math.max(sum,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 i=1; i<= X; i++) {
      for (int j=2; j<= 10; j++) {
        int sum = (int)Math.pow(i,j);
        if (sum <= X) {
          max = Math.max(sum,max);
        }
      }
    } int i=1; int i=1; i 1 i<= X i X i++ i++ i {
      for (int j=2; j<= 10; j++) {
        int sum = (int)Math.pow(i,j);
        if (sum <= X) {
          max = Math.max(sum,max);
        }
      }
    } {
      for (int j=2; j<= 10; j++) {
        int sum = (int)Math.pow(i,j);
        if (sum <= X) {
          max = Math.max(sum,max);
        }
      }
    } for (int j=2; j<= 10; j++) {
        int sum = (int)Math.pow(i,j);
        if (sum <= X) {
          max = Math.max(sum,max);
        }
      } int j=2; int j=2; j 2 j<= 10 j 10 j++ j++ j {
        int sum = (int)Math.pow(i,j);
        if (sum <= X) {
          max = Math.max(sum,max);
        }
      } {
        int sum = (int)Math.pow(i,j);
        if (sum <= X) {
          max = Math.max(sum,max);
        }
      } int sum = (int)Math.pow(i,j); sum (int)Math.pow(i,j) Math.pow Math i j if (sum <= X) {
          max = Math.max(sum,max);
        } sum <= X sum X {
          max = Math.max(sum,max);
        } max = Math.max(sum,max) max Math.max(sum,max) Math.max Math sum 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 i=1; i<= X; i++) {
      for (int j=2; j<= 10; j++) {
        int sum = (int)Math.pow(i,j);
        if (sum <= X) {
          max = Math.max(sum,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 i=1; i<= X; i++) {
      for (int j=2; j<= 10; j++) {
        int sum = (int)Math.pow(i,j);
        if (sum <= X) {
          max = Math.max(sum,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 i=1; i<= X; i++) {
      for (int j=2; j<= 10; j++) {
        int sum = (int)Math.pow(i,j);
        if (sum <= X) {
          max = Math.max(sum,max);
        }
      }
    }
    System.out.println(max);
  }
}