import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int X = Integer.parseInt(sc.next());
        final int N = (int)Math.sqrt(X) + 1;
        int ans = 1;
        
        for (int i = 1; i <= N; i++) {
            for (int j = 2; j <= N; j++) {
                int x = (int)Math.pow(i, j);
                if (x <= X) ans = Math.max(x, ans);
            }
        }

        out.println(ans);
        
        out.flush();
    }
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int X = Integer.parseInt(sc.next());
        final int N = (int)Math.sqrt(X) + 1;
        int ans = 1;
        
        for (int i = 1; i <= N; i++) {
            for (int j = 2; j <= N; j++) {
                int x = (int)Math.pow(i, j);
                if (x <= X) ans = Math.max(x, ans);
            }
        }

        out.println(ans);
        
        out.flush();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int X = Integer.parseInt(sc.next());
        final int N = (int)Math.sqrt(X) + 1;
        int ans = 1;
        
        for (int i = 1; i <= N; i++) {
            for (int j = 2; j <= N; j++) {
                int x = (int)Math.pow(i, j);
                if (x <= X) ans = Math.max(x, ans);
            }
        }

        out.println(ans);
        
        out.flush();
    } main {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int X = Integer.parseInt(sc.next());
        final int N = (int)Math.sqrt(X) + 1;
        int ans = 1;
        
        for (int i = 1; i <= N; i++) {
            for (int j = 2; j <= N; j++) {
                int x = (int)Math.pow(i, j);
                if (x <= X) ans = Math.max(x, ans);
            }
        }

        out.println(ans);
        
        out.flush();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) final int X = Integer.parseInt(sc.next()); X Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc final int N = (int)Math.sqrt(X) + 1; N (int)Math.sqrt(X) + 1 (int)Math.sqrt(X) Math.sqrt Math X 1 int ans = 1; ans 1 for (int i = 1; i <= N; i++) {
            for (int j = 2; j <= N; j++) {
                int x = (int)Math.pow(i, j);
                if (x <= X) ans = Math.max(x, ans);
            }
        } int i = 1; int i = 1; i 1 i <= N i N i++ i++ i {
            for (int j = 2; j <= N; j++) {
                int x = (int)Math.pow(i, j);
                if (x <= X) ans = Math.max(x, ans);
            }
        } {
            for (int j = 2; j <= N; j++) {
                int x = (int)Math.pow(i, j);
                if (x <= X) ans = Math.max(x, ans);
            }
        } for (int j = 2; j <= N; j++) {
                int x = (int)Math.pow(i, j);
                if (x <= X) ans = Math.max(x, ans);
            } int j = 2; int j = 2; j 2 j <= N j N j++ j++ j {
                int x = (int)Math.pow(i, j);
                if (x <= X) ans = Math.max(x, ans);
            } {
                int x = (int)Math.pow(i, j);
                if (x <= X) ans = Math.max(x, ans);
            } int x = (int)Math.pow(i, j); x (int)Math.pow(i, j) Math.pow Math i j if (x <= X) ans = Math.max(x, ans); x <= X x X ans = Math.max(x, ans) ans Math.max(x, ans) Math.max Math x ans out.println(ans) out.println out ans out.flush() out.flush out String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int X = Integer.parseInt(sc.next());
        final int N = (int)Math.sqrt(X) + 1;
        int ans = 1;
        
        for (int i = 1; i <= N; i++) {
            for (int j = 2; j <= N; j++) {
                int x = (int)Math.pow(i, j);
                if (x <= X) ans = Math.max(x, ans);
            }
        }

        out.println(ans);
        
        out.flush();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int X = Integer.parseInt(sc.next());
        final int N = (int)Math.sqrt(X) + 1;
        int ans = 1;
        
        for (int i = 1; i <= N; i++) {
            for (int j = 2; j <= N; j++) {
                int x = (int)Math.pow(i, j);
                if (x <= X) ans = Math.max(x, ans);
            }
        }

        out.println(ans);
        
        out.flush();
    }
} Main
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int X = Integer.parseInt(sc.next());
        final int N = (int)Math.sqrt(X) + 1;
        int ans = 1;
        
        for (int i = 1; i <= N; i++) {
            for (int j = 2; j <= N; j++) {
                int x = (int)Math.pow(i, j);
                if (x <= X) ans = Math.max(x, ans);
            }
        }

        out.println(ans);
        
        out.flush();
    }
}