import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int upper = (int) Math.sqrt(X)+1;
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        pq.add(1);
        int base = 2;
        while(base<=upper){
            int cur = base*base;
            while(cur<=X){
                pq.add(cur);
                cur = cur*base;
            }
            base++;
        }
        int ans = 0;
        while(pq.size()>1) ans = pq.poll();
        ans = pq.poll();

        System.out.println(ans);
    }
} import java.util.HashSet; HashSet java.util import java.util.PriorityQueue; PriorityQueue java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int upper = (int) Math.sqrt(X)+1;
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        pq.add(1);
        int base = 2;
        while(base<=upper){
            int cur = base*base;
            while(cur<=X){
                pq.add(cur);
                cur = cur*base;
            }
            base++;
        }
        int ans = 0;
        while(pq.size()>1) ans = pq.poll();
        ans = pq.poll();

        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int upper = (int) Math.sqrt(X)+1;
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        pq.add(1);
        int base = 2;
        while(base<=upper){
            int cur = base*base;
            while(cur<=X){
                pq.add(cur);
                cur = cur*base;
            }
            base++;
        }
        int ans = 0;
        while(pq.size()>1) ans = pq.poll();
        ans = pq.poll();

        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int upper = (int) Math.sqrt(X)+1;
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        pq.add(1);
        int base = 2;
        while(base<=upper){
            int cur = base*base;
            while(cur<=X){
                pq.add(cur);
                cur = cur*base;
            }
            base++;
        }
        int ans = 0;
        while(pq.size()>1) ans = pq.poll();
        ans = pq.poll();

        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc int upper = (int) Math.sqrt(X)+1; upper (int) Math.sqrt(X)+1 (int) Math.sqrt(X) Math.sqrt Math X 1 PriorityQueue<Integer> pq = new PriorityQueue<>(); pq new PriorityQueue<>() pq.add(1) pq.add pq 1 int base = 2; base 2 while(base<=upper){
            int cur = base*base;
            while(cur<=X){
                pq.add(cur);
                cur = cur*base;
            }
            base++;
        } base<=upper base upper {
            int cur = base*base;
            while(cur<=X){
                pq.add(cur);
                cur = cur*base;
            }
            base++;
        } int cur = base*base; cur base*base base base while(cur<=X){
                pq.add(cur);
                cur = cur*base;
            } cur<=X cur X {
                pq.add(cur);
                cur = cur*base;
            } pq.add(cur) pq.add pq cur cur = cur*base cur cur*base cur base base++ base int ans = 0; ans 0 while(pq.size()>1) ans = pq.poll(); pq.size()>1 pq.size() pq.size pq 1 ans = pq.poll() ans pq.poll() pq.poll pq ans = pq.poll() ans pq.poll() pq.poll pq 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 sc = new Scanner(System.in);
        int X = sc.nextInt();
        int upper = (int) Math.sqrt(X)+1;
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        pq.add(1);
        int base = 2;
        while(base<=upper){
            int cur = base*base;
            while(cur<=X){
                pq.add(cur);
                cur = cur*base;
            }
            base++;
        }
        int ans = 0;
        while(pq.size()>1) ans = pq.poll();
        ans = pq.poll();

        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int upper = (int) Math.sqrt(X)+1;
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        pq.add(1);
        int base = 2;
        while(base<=upper){
            int cur = base*base;
            while(cur<=X){
                pq.add(cur);
                cur = cur*base;
            }
            base++;
        }
        int ans = 0;
        while(pq.size()>1) ans = pq.poll();
        ans = pq.poll();

        System.out.println(ans);
    }
} Main
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int upper = (int) Math.sqrt(X)+1;
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        pq.add(1);
        int base = 2;
        while(base<=upper){
            int cur = base*base;
            while(cur<=X){
                pq.add(cur);
                cur = cur*base;
            }
            base++;
        }
        int ans = 0;
        while(pq.size()>1) ans = pq.poll();
        ans = pq.poll();

        System.out.println(ans);
    }
}