import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        double ans = 1;

        for (int i = 1; i < x; i++) {
        	loop1:
        	for (int j = 2; j < x; j++) {
        		if (Math.pow(i, j) > x) {
        			break loop1;
        		}
        		if (ans < Math.pow(i, j)) {
        			ans = Math.pow(i, j);
        		}
        	}
        }
        System.out.println((int)ans);

        sc.close();
    }    
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        double ans = 1;

        for (int i = 1; i < x; i++) {
        	loop1:
        	for (int j = 2; j < x; j++) {
        		if (Math.pow(i, j) > x) {
        			break loop1;
        		}
        		if (ans < Math.pow(i, j)) {
        			ans = Math.pow(i, j);
        		}
        	}
        }
        System.out.println((int)ans);

        sc.close();
    }    
} Main public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        double ans = 1;

        for (int i = 1; i < x; i++) {
        	loop1:
        	for (int j = 2; j < x; j++) {
        		if (Math.pow(i, j) > x) {
        			break loop1;
        		}
        		if (ans < Math.pow(i, j)) {
        			ans = Math.pow(i, j);
        		}
        	}
        }
        System.out.println((int)ans);

        sc.close();
    } main {
        
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        double ans = 1;

        for (int i = 1; i < x; i++) {
        	loop1:
        	for (int j = 2; j < x; j++) {
        		if (Math.pow(i, j) > x) {
        			break loop1;
        		}
        		if (ans < Math.pow(i, j)) {
        			ans = Math.pow(i, j);
        		}
        	}
        }
        System.out.println((int)ans);

        sc.close();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc double ans = 1; ans 1 for (int i = 1; i < x; i++) {
        	loop1:
        	for (int j = 2; j < x; j++) {
        		if (Math.pow(i, j) > x) {
        			break loop1;
        		}
        		if (ans < Math.pow(i, j)) {
        			ans = Math.pow(i, j);
        		}
        	}
        } int i = 1; int i = 1; i 1 i < x i x i++ i++ i {
        	loop1:
        	for (int j = 2; j < x; j++) {
        		if (Math.pow(i, j) > x) {
        			break loop1;
        		}
        		if (ans < Math.pow(i, j)) {
        			ans = Math.pow(i, j);
        		}
        	}
        } {
        	loop1:
        	for (int j = 2; j < x; j++) {
        		if (Math.pow(i, j) > x) {
        			break loop1;
        		}
        		if (ans < Math.pow(i, j)) {
        			ans = Math.pow(i, j);
        		}
        	}
        } System.out.println((int)ans) System.out.println System.out System System.out (int)ans sc.close() sc.close sc String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        double ans = 1;

        for (int i = 1; i < x; i++) {
        	loop1:
        	for (int j = 2; j < x; j++) {
        		if (Math.pow(i, j) > x) {
        			break loop1;
        		}
        		if (ans < Math.pow(i, j)) {
        			ans = Math.pow(i, j);
        		}
        	}
        }
        System.out.println((int)ans);

        sc.close();
    }    
} public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        double ans = 1;

        for (int i = 1; i < x; i++) {
        	loop1:
        	for (int j = 2; j < x; j++) {
        		if (Math.pow(i, j) > x) {
        			break loop1;
        		}
        		if (ans < Math.pow(i, j)) {
        			ans = Math.pow(i, j);
        		}
        	}
        }
        System.out.println((int)ans);

        sc.close();
    }    
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        double ans = 1;

        for (int i = 1; i < x; i++) {
        	loop1:
        	for (int j = 2; j < x; j++) {
        		if (Math.pow(i, j) > x) {
        			break loop1;
        		}
        		if (ans < Math.pow(i, j)) {
        			ans = Math.pow(i, j);
        		}
        	}
        }
        System.out.println((int)ans);

        sc.close();
    }    
}
