import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        boolean[] a = new boolean[x+1];
        a[1] = true;
        for(int i = 2; i < x; i++) {
            int t = i * i;
            while(t <= x) {
                a[t] = true;
                t *= i;
            }
        }
        int ans = x;
        while(!a[ans]) ans--;
        System.out.println(ans);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        boolean[] a = new boolean[x+1];
        a[1] = true;
        for(int i = 2; i < x; i++) {
            int t = i * i;
            while(t <= x) {
                a[t] = true;
                t *= i;
            }
        }
        int ans = x;
        while(!a[ans]) ans--;
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        boolean[] a = new boolean[x+1];
        a[1] = true;
        for(int i = 2; i < x; i++) {
            int t = i * i;
            while(t <= x) {
                a[t] = true;
                t *= i;
            }
        }
        int ans = x;
        while(!a[ans]) ans--;
        System.out.println(ans);
    } main {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        boolean[] a = new boolean[x+1];
        a[1] = true;
        for(int i = 2; i < x; i++) {
            int t = i * i;
            while(t <= x) {
                a[t] = true;
                t *= i;
            }
        }
        int ans = x;
        while(!a[ans]) ans--;
        System.out.println(ans);
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int x = in.nextInt(); x in.nextInt() in.nextInt in boolean[] a = new boolean[x+1]; a new boolean[x+1] x+1 x 1 a[1] = true a[1] a 1 true for(int i = 2; i < x; i++) {
            int t = i * i;
            while(t <= x) {
                a[t] = true;
                t *= i;
            }
        } int i = 2; int i = 2; i 2 i < x i x i++ i++ i {
            int t = i * i;
            while(t <= x) {
                a[t] = true;
                t *= i;
            }
        } {
            int t = i * i;
            while(t <= x) {
                a[t] = true;
                t *= i;
            }
        } int t = i * i; t i * i i i while(t <= x) {
                a[t] = true;
                t *= i;
            } t <= x t x {
                a[t] = true;
                t *= i;
            } a[t] = true a[t] a t true t *= i t i int ans = x; ans x while(!a[ans]) ans--; !a[ans] a[ans] a ans ans-- ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        boolean[] a = new boolean[x+1];
        a[1] = true;
        for(int i = 2; i < x; i++) {
            int t = i * i;
            while(t <= x) {
                a[t] = true;
                t *= i;
            }
        }
        int ans = x;
        while(!a[ans]) ans--;
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        boolean[] a = new boolean[x+1];
        a[1] = true;
        for(int i = 2; i < x; i++) {
            int t = i * i;
            while(t <= x) {
                a[t] = true;
                t *= i;
            }
        }
        int ans = x;
        while(!a[ans]) ans--;
        System.out.println(ans);
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        boolean[] a = new boolean[x+1];
        a[1] = true;
        for(int i = 2; i < x; i++) {
            int t = i * i;
            while(t <= x) {
                a[t] = true;
                t *= i;
            }
        }
        int ans = x;
        while(!a[ans]) ans--;
        System.out.println(ans);
    }
}