import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int x = scan.nextInt();
        System.out.println(solve(x));
    }
    public static int solve(int x) {
        int upper = (int) Math.floor(Math.sqrt(x));
        int answer = 0;
        for (int i = 1; i <= upper; i++) {
            for (int j = 1; j <= 10; j++) {
                int target = (int) Math.pow(i, j);
                if (x < target) {
                    break;
                }
                if (target <= x && answer < target) {
                    answer = target;
                }
                if (i == 1) {
                    break;
                }
            }
        }
        return answer;
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int x = scan.nextInt();
        System.out.println(solve(x));
    }
    public static int solve(int x) {
        int upper = (int) Math.floor(Math.sqrt(x));
        int answer = 0;
        for (int i = 1; i <= upper; i++) {
            for (int j = 1; j <= 10; j++) {
                int target = (int) Math.pow(i, j);
                if (x < target) {
                    break;
                }
                if (target <= x && answer < target) {
                    answer = target;
                }
                if (i == 1) {
                    break;
                }
            }
        }
        return answer;
    }
} Main public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int x = scan.nextInt();
        System.out.println(solve(x));
    } main {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int x = scan.nextInt();
        System.out.println(solve(x));
    } Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in))); scan new Scanner(new BufferedReader(new InputStreamReader(System.in))) int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan System.out.println(solve(x)) System.out.println System.out System System.out solve(x) solve x String[] args args public static int solve(int x) {
        int upper = (int) Math.floor(Math.sqrt(x));
        int answer = 0;
        for (int i = 1; i <= upper; i++) {
            for (int j = 1; j <= 10; j++) {
                int target = (int) Math.pow(i, j);
                if (x < target) {
                    break;
                }
                if (target <= x && answer < target) {
                    answer = target;
                }
                if (i == 1) {
                    break;
                }
            }
        }
        return answer;
    } solve {
        int upper = (int) Math.floor(Math.sqrt(x));
        int answer = 0;
        for (int i = 1; i <= upper; i++) {
            for (int j = 1; j <= 10; j++) {
                int target = (int) Math.pow(i, j);
                if (x < target) {
                    break;
                }
                if (target <= x && answer < target) {
                    answer = target;
                }
                if (i == 1) {
                    break;
                }
            }
        }
        return answer;
    } int upper = (int) Math.floor(Math.sqrt(x)); upper (int) Math.floor(Math.sqrt(x)) Math.floor Math Math.sqrt(x) Math.sqrt Math x int answer = 0; answer 0 for (int i = 1; i <= upper; i++) {
            for (int j = 1; j <= 10; j++) {
                int target = (int) Math.pow(i, j);
                if (x < target) {
                    break;
                }
                if (target <= x && answer < target) {
                    answer = target;
                }
                if (i == 1) {
                    break;
                }
            }
        } int i = 1; int i = 1; i 1 i <= upper i upper i++ i++ i {
            for (int j = 1; j <= 10; j++) {
                int target = (int) Math.pow(i, j);
                if (x < target) {
                    break;
                }
                if (target <= x && answer < target) {
                    answer = target;
                }
                if (i == 1) {
                    break;
                }
            }
        } {
            for (int j = 1; j <= 10; j++) {
                int target = (int) Math.pow(i, j);
                if (x < target) {
                    break;
                }
                if (target <= x && answer < target) {
                    answer = target;
                }
                if (i == 1) {
                    break;
                }
            }
        } for (int j = 1; j <= 10; j++) {
                int target = (int) Math.pow(i, j);
                if (x < target) {
                    break;
                }
                if (target <= x && answer < target) {
                    answer = target;
                }
                if (i == 1) {
                    break;
                }
            } int j = 1; int j = 1; j 1 j <= 10 j 10 j++ j++ j {
                int target = (int) Math.pow(i, j);
                if (x < target) {
                    break;
                }
                if (target <= x && answer < target) {
                    answer = target;
                }
                if (i == 1) {
                    break;
                }
            } {
                int target = (int) Math.pow(i, j);
                if (x < target) {
                    break;
                }
                if (target <= x && answer < target) {
                    answer = target;
                }
                if (i == 1) {
                    break;
                }
            } int target = (int) Math.pow(i, j); target (int) Math.pow(i, j) Math.pow Math i j if (x < target) {
                    break;
                } x < target x target {
                    break;
                } break; if (target <= x && answer < target) {
                    answer = target;
                } target <= x && answer < target target <= x target x answer < target answer target {
                    answer = target;
                } answer = target answer target if (i == 1) {
                    break;
                } i == 1 i 1 {
                    break;
                } break; return answer; answer int x x public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int x = scan.nextInt();
        System.out.println(solve(x));
    }
    public static int solve(int x) {
        int upper = (int) Math.floor(Math.sqrt(x));
        int answer = 0;
        for (int i = 1; i <= upper; i++) {
            for (int j = 1; j <= 10; j++) {
                int target = (int) Math.pow(i, j);
                if (x < target) {
                    break;
                }
                if (target <= x && answer < target) {
                    answer = target;
                }
                if (i == 1) {
                    break;
                }
            }
        }
        return answer;
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int x = scan.nextInt();
        System.out.println(solve(x));
    }
    public static int solve(int x) {
        int upper = (int) Math.floor(Math.sqrt(x));
        int answer = 0;
        for (int i = 1; i <= upper; i++) {
            for (int j = 1; j <= 10; j++) {
                int target = (int) Math.pow(i, j);
                if (x < target) {
                    break;
                }
                if (target <= x && answer < target) {
                    answer = target;
                }
                if (i == 1) {
                    break;
                }
            }
        }
        return answer;
    }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int x = scan.nextInt();
        System.out.println(solve(x));
    }
    public static int solve(int x) {
        int upper = (int) Math.floor(Math.sqrt(x));
        int answer = 0;
        for (int i = 1; i <= upper; i++) {
            for (int j = 1; j <= 10; j++) {
                int target = (int) Math.pow(i, j);
                if (x < target) {
                    break;
                }
                if (target <= x && answer < target) {
                    answer = target;
                }
                if (i == 1) {
                    break;
                }
            }
        }
        return answer;
    }
}
