import java.util.*;
import java.lang.Math;

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

        int x = sc.nextInt();
        int max = 1;
        int i = 2;

        while (i * i <= x) {
            int m = i * i;
            while (m <= x) {
                if (m > max) {
                    max = m;
                }
                m *= i;
            }
            i++;
        }

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

        int x = sc.nextInt();
        int max = 1;
        int i = 2;

        while (i * i <= x) {
            int m = i * i;
            while (m <= x) {
                if (m > max) {
                    max = m;
                }
                m *= i;
            }
            i++;
        }

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

        int x = sc.nextInt();
        int max = 1;
        int i = 2;

        while (i * i <= x) {
            int m = i * i;
            while (m <= x) {
                if (m > max) {
                    max = m;
                }
                m *= i;
            }
            i++;
        }

        System.out.println(max);
    } main {
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int max = 1;
        int i = 2;

        while (i * i <= x) {
            int m = i * i;
            while (m <= x) {
                if (m > max) {
                    max = m;
                }
                m *= i;
            }
            i++;
        }

        System.out.println(max);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc int max = 1; max 1 int i = 2; i 2 while (i * i <= x) {
            int m = i * i;
            while (m <= x) {
                if (m > max) {
                    max = m;
                }
                m *= i;
            }
            i++;
        } i * i <= x i * i i i x {
            int m = i * i;
            while (m <= x) {
                if (m > max) {
                    max = m;
                }
                m *= i;
            }
            i++;
        } int m = i * i; m i * i i i while (m <= x) {
                if (m > max) {
                    max = m;
                }
                m *= i;
            } m <= x m x {
                if (m > max) {
                    max = m;
                }
                m *= i;
            } if (m > max) {
                    max = m;
                } m > max m max {
                    max = m;
                } max = m max m m *= i m i i++ i System.out.println(max) System.out.println System.out System System.out max String args[] args public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int max = 1;
        int i = 2;

        while (i * i <= x) {
            int m = i * i;
            while (m <= x) {
                if (m > max) {
                    max = m;
                }
                m *= i;
            }
            i++;
        }

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

        int x = sc.nextInt();
        int max = 1;
        int i = 2;

        while (i * i <= x) {
            int m = i * i;
            while (m <= x) {
                if (m > max) {
                    max = m;
                }
                m *= i;
            }
            i++;
        }

        System.out.println(max);
    }
} Main
import java.util.*;
import java.lang.Math;

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

        int x = sc.nextInt();
        int max = 1;
        int i = 2;

        while (i * i <= x) {
            int m = i * i;
            while (m <= x) {
                if (m > max) {
                    max = m;
                }
                m *= i;
            }
            i++;
        }

        System.out.println(max);
    }
}
