import java.util.*;

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

        if(x == 1 || x == 2) {
            System.out.println(1);
        } else if(x == 1000) {
            System.out.println(1000);
        } else {
            for(int i = x; i >= 1; i--) {
                if(isPower(i)) {
                    System.out.println(i);
                    break;
                }
            }
        }

    }

    public static boolean isPower(int n) {
        if(n == 1) {
            return false;
        } else {
            for(int i = 2; Math.pow(n, 1.0/i) >= 2.0; i++) {
                double d = Math.pow(n, 1.0/i);
                if(d - Math.floor(d) < 0.00001)
                    return true;
            }
        }

        return false;
    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();

        if(x == 1 || x == 2) {
            System.out.println(1);
        } else if(x == 1000) {
            System.out.println(1000);
        } else {
            for(int i = x; i >= 1; i--) {
                if(isPower(i)) {
                    System.out.println(i);
                    break;
                }
            }
        }

    }

    public static boolean isPower(int n) {
        if(n == 1) {
            return false;
        } else {
            for(int i = 2; Math.pow(n, 1.0/i) >= 2.0; i++) {
                double d = Math.pow(n, 1.0/i);
                if(d - Math.floor(d) < 0.00001)
                    return true;
            }
        }

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

        if(x == 1 || x == 2) {
            System.out.println(1);
        } else if(x == 1000) {
            System.out.println(1000);
        } else {
            for(int i = x; i >= 1; i--) {
                if(isPower(i)) {
                    System.out.println(i);
                    break;
                }
            }
        }

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

        if(x == 1 || x == 2) {
            System.out.println(1);
        } else if(x == 1000) {
            System.out.println(1000);
        } else {
            for(int i = x; i >= 1; i--) {
                if(isPower(i)) {
                    System.out.println(i);
                    break;
                }
            }
        }

    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int x = in.nextInt(); x in.nextInt() in.nextInt in if(x == 1 || x == 2) {
            System.out.println(1);
        } else if(x == 1000) {
            System.out.println(1000);
        } else {
            for(int i = x; i >= 1; i--) {
                if(isPower(i)) {
                    System.out.println(i);
                    break;
                }
            }
        } x == 1 || x == 2 x == 1 x 1 x == 2 x 2 {
            System.out.println(1);
        } System.out.println(1) System.out.println System.out System System.out 1 if(x == 1000) {
            System.out.println(1000);
        } else {
            for(int i = x; i >= 1; i--) {
                if(isPower(i)) {
                    System.out.println(i);
                    break;
                }
            }
        } x == 1000 x 1000 {
            System.out.println(1000);
        } System.out.println(1000) System.out.println System.out System System.out 1000 {
            for(int i = x; i >= 1; i--) {
                if(isPower(i)) {
                    System.out.println(i);
                    break;
                }
            }
        } for(int i = x; i >= 1; i--) {
                if(isPower(i)) {
                    System.out.println(i);
                    break;
                }
            } int i = x; int i = x; i x i >= 1 i 1 i-- i-- i {
                if(isPower(i)) {
                    System.out.println(i);
                    break;
                }
            } {
                if(isPower(i)) {
                    System.out.println(i);
                    break;
                }
            } if(isPower(i)) {
                    System.out.println(i);
                    break;
                } isPower(i) isPower i {
                    System.out.println(i);
                    break;
                } System.out.println(i) System.out.println System.out System System.out i break; String[] args args public static boolean isPower(int n) {
        if(n == 1) {
            return false;
        } else {
            for(int i = 2; Math.pow(n, 1.0/i) >= 2.0; i++) {
                double d = Math.pow(n, 1.0/i);
                if(d - Math.floor(d) < 0.00001)
                    return true;
            }
        }

        return false;
    } isPower {
        if(n == 1) {
            return false;
        } else {
            for(int i = 2; Math.pow(n, 1.0/i) >= 2.0; i++) {
                double d = Math.pow(n, 1.0/i);
                if(d - Math.floor(d) < 0.00001)
                    return true;
            }
        }

        return false;
    } if(n == 1) {
            return false;
        } else {
            for(int i = 2; Math.pow(n, 1.0/i) >= 2.0; i++) {
                double d = Math.pow(n, 1.0/i);
                if(d - Math.floor(d) < 0.00001)
                    return true;
            }
        } n == 1 n 1 {
            return false;
        } return false; false {
            for(int i = 2; Math.pow(n, 1.0/i) >= 2.0; i++) {
                double d = Math.pow(n, 1.0/i);
                if(d - Math.floor(d) < 0.00001)
                    return true;
            }
        } for(int i = 2; Math.pow(n, 1.0/i) >= 2.0; i++) {
                double d = Math.pow(n, 1.0/i);
                if(d - Math.floor(d) < 0.00001)
                    return true;
            } int i = 2; int i = 2; i 2 Math.pow(n, 1.0/i) >= 2.0 Math.pow(n, 1.0/i) Math.pow Math n 1.0/i 1.0 i 2.0 i++ i++ i {
                double d = Math.pow(n, 1.0/i);
                if(d - Math.floor(d) < 0.00001)
                    return true;
            } {
                double d = Math.pow(n, 1.0/i);
                if(d - Math.floor(d) < 0.00001)
                    return true;
            } double d = Math.pow(n, 1.0/i); d Math.pow(n, 1.0/i) Math.pow Math n 1.0/i 1.0 i if(d - Math.floor(d) < 0.00001)
                    return true; d - Math.floor(d) < 0.00001 d - Math.floor(d) d Math.floor(d) Math.floor Math d 0.00001 return true; true return false; false int n n
import java.util.*;

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

        if(x == 1 || x == 2) {
            System.out.println(1);
        } else if(x == 1000) {
            System.out.println(1000);
        } else {
            for(int i = x; i >= 1; i--) {
                if(isPower(i)) {
                    System.out.println(i);
                    break;
                }
            }
        }

    }

    public static boolean isPower(int n) {
        if(n == 1) {
            return false;
        } else {
            for(int i = 2; Math.pow(n, 1.0/i) >= 2.0; i++) {
                double d = Math.pow(n, 1.0/i);
                if(d - Math.floor(d) < 0.00001)
                    return true;
            }
        }

        return false;
    }
}