import java.io.PrintWriter;
import java.util.Scanner;


public class Main {

  private static final Scanner in = new Scanner(System.in);
  private static final PrintWriter out = new PrintWriter(System.out);

  private static int[] nextArray(int n) {
    int[] arr = new int[n];
    for (int i = 0; i < n; i++) {
      arr[i] = in.nextInt();
    }
    return arr;
  }

  public static void main(String[] args) {
    int a = in.nextInt();
    solve(a);
    out.flush();
    out.close();
  }

  private static void solve(int a) {
    int res = 0;
    for (int i = 1; i <= a; i++) {
      for (int j = 2; j < 10; j++) {
        if (Math.pow(i, j) <= a) {
          res = (int) Math.max(res, Math.pow(i, j));
        }
      }
    }
    if (res == 0) {
      res = a;
    }
    out.println(res);

  }
  
} import java.io.PrintWriter; PrintWriter java.io import java.util.Scanner; Scanner java.util public class Main {

  private static final Scanner in = new Scanner(System.in);
  private static final PrintWriter out = new PrintWriter(System.out);

  private static int[] nextArray(int n) {
    int[] arr = new int[n];
    for (int i = 0; i < n; i++) {
      arr[i] = in.nextInt();
    }
    return arr;
  }

  public static void main(String[] args) {
    int a = in.nextInt();
    solve(a);
    out.flush();
    out.close();
  }

  private static void solve(int a) {
    int res = 0;
    for (int i = 1; i <= a; i++) {
      for (int j = 2; j < 10; j++) {
        if (Math.pow(i, j) <= a) {
          res = (int) Math.max(res, Math.pow(i, j));
        }
      }
    }
    if (res == 0) {
      res = a;
    }
    out.println(res);

  }
  
} Main private static final Scanner in = new Scanner(System.in); in new Scanner(System.in) private static final PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) private static int[] nextArray(int n) {
    int[] arr = new int[n];
    for (int i = 0; i < n; i++) {
      arr[i] = in.nextInt();
    }
    return arr;
  } nextArray {
    int[] arr = new int[n];
    for (int i = 0; i < n; i++) {
      arr[i] = in.nextInt();
    }
    return arr;
  } int[] arr = new int[n]; arr new int[n] n for (int i = 0; i < n; i++) {
      arr[i] = in.nextInt();
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      arr[i] = in.nextInt();
    } {
      arr[i] = in.nextInt();
    } arr[i] = in.nextInt() arr[i] arr i in.nextInt() in.nextInt in return arr; arr int n n public static void main(String[] args) {
    int a = in.nextInt();
    solve(a);
    out.flush();
    out.close();
  } main {
    int a = in.nextInt();
    solve(a);
    out.flush();
    out.close();
  } int a = in.nextInt(); a in.nextInt() in.nextInt in solve(a) solve a out.flush() out.flush out out.close() out.close out String[] args args private static void solve(int a) {
    int res = 0;
    for (int i = 1; i <= a; i++) {
      for (int j = 2; j < 10; j++) {
        if (Math.pow(i, j) <= a) {
          res = (int) Math.max(res, Math.pow(i, j));
        }
      }
    }
    if (res == 0) {
      res = a;
    }
    out.println(res);

  } solve {
    int res = 0;
    for (int i = 1; i <= a; i++) {
      for (int j = 2; j < 10; j++) {
        if (Math.pow(i, j) <= a) {
          res = (int) Math.max(res, Math.pow(i, j));
        }
      }
    }
    if (res == 0) {
      res = a;
    }
    out.println(res);

  } int res = 0; res 0 for (int i = 1; i <= a; i++) {
      for (int j = 2; j < 10; j++) {
        if (Math.pow(i, j) <= a) {
          res = (int) Math.max(res, Math.pow(i, j));
        }
      }
    } int i = 1; int i = 1; i 1 i <= a i a i++ i++ i {
      for (int j = 2; j < 10; j++) {
        if (Math.pow(i, j) <= a) {
          res = (int) Math.max(res, Math.pow(i, j));
        }
      }
    } {
      for (int j = 2; j < 10; j++) {
        if (Math.pow(i, j) <= a) {
          res = (int) Math.max(res, Math.pow(i, j));
        }
      }
    } for (int j = 2; j < 10; j++) {
        if (Math.pow(i, j) <= a) {
          res = (int) Math.max(res, Math.pow(i, j));
        }
      } int j = 2; int j = 2; j 2 j < 10 j 10 j++ j++ j {
        if (Math.pow(i, j) <= a) {
          res = (int) Math.max(res, Math.pow(i, j));
        }
      } {
        if (Math.pow(i, j) <= a) {
          res = (int) Math.max(res, Math.pow(i, j));
        }
      } if (Math.pow(i, j) <= a) {
          res = (int) Math.max(res, Math.pow(i, j));
        } Math.pow(i, j) <= a Math.pow(i, j) Math.pow Math i j a {
          res = (int) Math.max(res, Math.pow(i, j));
        } res = (int) Math.max(res, Math.pow(i, j)) res (int) Math.max(res, Math.pow(i, j)) Math.max Math res Math.pow(i, j) Math.pow Math i j if (res == 0) {
      res = a;
    } res == 0 res 0 {
      res = a;
    } res = a res a out.println(res) out.println out res int a a public class Main {

  private static final Scanner in = new Scanner(System.in);
  private static final PrintWriter out = new PrintWriter(System.out);

  private static int[] nextArray(int n) {
    int[] arr = new int[n];
    for (int i = 0; i < n; i++) {
      arr[i] = in.nextInt();
    }
    return arr;
  }

  public static void main(String[] args) {
    int a = in.nextInt();
    solve(a);
    out.flush();
    out.close();
  }

  private static void solve(int a) {
    int res = 0;
    for (int i = 1; i <= a; i++) {
      for (int j = 2; j < 10; j++) {
        if (Math.pow(i, j) <= a) {
          res = (int) Math.max(res, Math.pow(i, j));
        }
      }
    }
    if (res == 0) {
      res = a;
    }
    out.println(res);

  }
  
} public class Main {

  private static final Scanner in = new Scanner(System.in);
  private static final PrintWriter out = new PrintWriter(System.out);

  private static int[] nextArray(int n) {
    int[] arr = new int[n];
    for (int i = 0; i < n; i++) {
      arr[i] = in.nextInt();
    }
    return arr;
  }

  public static void main(String[] args) {
    int a = in.nextInt();
    solve(a);
    out.flush();
    out.close();
  }

  private static void solve(int a) {
    int res = 0;
    for (int i = 1; i <= a; i++) {
      for (int j = 2; j < 10; j++) {
        if (Math.pow(i, j) <= a) {
          res = (int) Math.max(res, Math.pow(i, j));
        }
      }
    }
    if (res == 0) {
      res = a;
    }
    out.println(res);

  }
  
} Main
import java.io.PrintWriter;
import java.util.Scanner;


public class Main {

  private static final Scanner in = new Scanner(System.in);
  private static final PrintWriter out = new PrintWriter(System.out);

  private static int[] nextArray(int n) {
    int[] arr = new int[n];
    for (int i = 0; i < n; i++) {
      arr[i] = in.nextInt();
    }
    return arr;
  }

  public static void main(String[] args) {
    int a = in.nextInt();
    solve(a);
    out.flush();
    out.close();
  }

  private static void solve(int a) {
    int res = 0;
    for (int i = 1; i <= a; i++) {
      for (int j = 2; j < 10; j++) {
        if (Math.pow(i, j) <= a) {
          res = (int) Math.max(res, Math.pow(i, j));
        }
      }
    }
    if (res == 0) {
      res = a;
    }
    out.println(res);

  }
  
}