import java.util.Scanner;
 
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        
        int max = 0;
        for (int B = 1; B < 32; B++) {
        	for (int P = 2; P < 10; P++) {
        		int pow = (int)Math.pow(B, P);
        		if (pow <= X && pow > max) {
        			max = pow;
        		}
        	}
        }
        
        System.out.println(max);
    }
    
} 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 max = 0;
        for (int B = 1; B < 32; B++) {
        	for (int P = 2; P < 10; P++) {
        		int pow = (int)Math.pow(B, P);
        		if (pow <= X && pow > max) {
        			max = pow;
        		}
        	}
        }
        
        System.out.println(max);
    }
    
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        
        int max = 0;
        for (int B = 1; B < 32; B++) {
        	for (int P = 2; P < 10; P++) {
        		int pow = (int)Math.pow(B, P);
        		if (pow <= X && pow > max) {
        			max = pow;
        		}
        	}
        }
        
        System.out.println(max);
    } main {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        
        int max = 0;
        for (int B = 1; B < 32; B++) {
        	for (int P = 2; P < 10; P++) {
        		int pow = (int)Math.pow(B, P);
        		if (pow <= X && pow > max) {
        			max = pow;
        		}
        	}
        }
        
        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 = 0; max 0 for (int B = 1; B < 32; B++) {
        	for (int P = 2; P < 10; P++) {
        		int pow = (int)Math.pow(B, P);
        		if (pow <= X && pow > max) {
        			max = pow;
        		}
        	}
        } int B = 1; int B = 1; B 1 B < 32 B 32 B++ B++ B {
        	for (int P = 2; P < 10; P++) {
        		int pow = (int)Math.pow(B, P);
        		if (pow <= X && pow > max) {
        			max = pow;
        		}
        	}
        } {
        	for (int P = 2; P < 10; P++) {
        		int pow = (int)Math.pow(B, P);
        		if (pow <= X && pow > max) {
        			max = pow;
        		}
        	}
        } for (int P = 2; P < 10; P++) {
        		int pow = (int)Math.pow(B, P);
        		if (pow <= X && pow > max) {
        			max = pow;
        		}
        	} int P = 2; int P = 2; P 2 P < 10 P 10 P++ P++ P {
        		int pow = (int)Math.pow(B, P);
        		if (pow <= X && pow > max) {
        			max = pow;
        		}
        	} {
        		int pow = (int)Math.pow(B, P);
        		if (pow <= X && pow > max) {
        			max = pow;
        		}
        	} int pow = (int)Math.pow(B, P); pow (int)Math.pow(B, P) Math.pow Math B P if (pow <= X && pow > max) {
        			max = pow;
        		} pow <= X && pow > max pow <= X pow X pow > max pow max {
        			max = pow;
        		} max = pow max pow 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 = 0;
        for (int B = 1; B < 32; B++) {
        	for (int P = 2; P < 10; P++) {
        		int pow = (int)Math.pow(B, P);
        		if (pow <= X && pow > max) {
        			max = pow;
        		}
        	}
        }
        
        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 = 0;
        for (int B = 1; B < 32; B++) {
        	for (int P = 2; P < 10; P++) {
        		int pow = (int)Math.pow(B, P);
        		if (pow <= X && pow > max) {
        			max = pow;
        		}
        	}
        }
        
        System.out.println(max);
    }
    
} Main
import java.util.Scanner;
 
public class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        
        int max = 0;
        for (int B = 1; B < 32; B++) {
        	for (int P = 2; P < 10; P++) {
        		int pow = (int)Math.pow(B, P);
        		if (pow <= X && pow > max) {
        			max = pow;
        		}
        	}
        }
        
        System.out.println(max);
    }
    
}