import java.util.Scanner;

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

	int x = scan.nextInt();

        double max = 0;
	for(int i = 1; i <= x; i++){
	    double beki = 0;
	    int p;
	    for(p = 2; p < 10; p++){
		beki = Math.pow(i, p);
		if(beki > x){
		    break;
		}
	    }
	    if(max < Math.pow(i, p-1) && (p-1) != 1){
		max = Math.pow(i, p-1);
	    }
	    
	}

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

	int x = scan.nextInt();

        double max = 0;
	for(int i = 1; i <= x; i++){
	    double beki = 0;
	    int p;
	    for(p = 2; p < 10; p++){
		beki = Math.pow(i, p);
		if(beki > x){
		    break;
		}
	    }
	    if(max < Math.pow(i, p-1) && (p-1) != 1){
		max = Math.pow(i, p-1);
	    }
	    
	}

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

	int x = scan.nextInt();

        double max = 0;
	for(int i = 1; i <= x; i++){
	    double beki = 0;
	    int p;
	    for(p = 2; p < 10; p++){
		beki = Math.pow(i, p);
		if(beki > x){
		    break;
		}
	    }
	    if(max < Math.pow(i, p-1) && (p-1) != 1){
		max = Math.pow(i, p-1);
	    }
	    
	}

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

	int x = scan.nextInt();

        double max = 0;
	for(int i = 1; i <= x; i++){
	    double beki = 0;
	    int p;
	    for(p = 2; p < 10; p++){
		beki = Math.pow(i, p);
		if(beki > x){
		    break;
		}
	    }
	    if(max < Math.pow(i, p-1) && (p-1) != 1){
		max = Math.pow(i, p-1);
	    }
	    
	}

	System.out.println((int)max);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int x = scan.nextInt(); x scan.nextInt() scan.nextInt scan double max = 0; max 0 for(int i = 1; i <= x; i++){
	    double beki = 0;
	    int p;
	    for(p = 2; p < 10; p++){
		beki = Math.pow(i, p);
		if(beki > x){
		    break;
		}
	    }
	    if(max < Math.pow(i, p-1) && (p-1) != 1){
		max = Math.pow(i, p-1);
	    }
	    
	} int i = 1; int i = 1; i 1 i <= x i x i++ i++ i {
	    double beki = 0;
	    int p;
	    for(p = 2; p < 10; p++){
		beki = Math.pow(i, p);
		if(beki > x){
		    break;
		}
	    }
	    if(max < Math.pow(i, p-1) && (p-1) != 1){
		max = Math.pow(i, p-1);
	    }
	    
	} {
	    double beki = 0;
	    int p;
	    for(p = 2; p < 10; p++){
		beki = Math.pow(i, p);
		if(beki > x){
		    break;
		}
	    }
	    if(max < Math.pow(i, p-1) && (p-1) != 1){
		max = Math.pow(i, p-1);
	    }
	    
	} double beki = 0; beki 0 int p; p for(p = 2; p < 10; p++){
		beki = Math.pow(i, p);
		if(beki > x){
		    break;
		}
	    } p = 2; p = 2 p 2 p < 10 p 10 p++ p++ p {
		beki = Math.pow(i, p);
		if(beki > x){
		    break;
		}
	    } {
		beki = Math.pow(i, p);
		if(beki > x){
		    break;
		}
	    } beki = Math.pow(i, p) beki Math.pow(i, p) Math.pow Math i p if(beki > x){
		    break;
		} beki > x beki x {
		    break;
		} break; if(max < Math.pow(i, p-1) && (p-1) != 1){
		max = Math.pow(i, p-1);
	    } max < Math.pow(i, p-1) && (p-1) != 1 max < Math.pow(i, p-1) max Math.pow(i, p-1) Math.pow Math i p-1 p 1 (p-1) != 1 (p-1) p 1 1 {
		max = Math.pow(i, p-1);
	    } max = Math.pow(i, p-1) max Math.pow(i, p-1) Math.pow Math i p-1 p 1 System.out.println((int)max) System.out.println System.out System System.out (int)max String[] args args public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int x = scan.nextInt();

        double max = 0;
	for(int i = 1; i <= x; i++){
	    double beki = 0;
	    int p;
	    for(p = 2; p < 10; p++){
		beki = Math.pow(i, p);
		if(beki > x){
		    break;
		}
	    }
	    if(max < Math.pow(i, p-1) && (p-1) != 1){
		max = Math.pow(i, p-1);
	    }
	    
	}

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

	int x = scan.nextInt();

        double max = 0;
	for(int i = 1; i <= x; i++){
	    double beki = 0;
	    int p;
	    for(p = 2; p < 10; p++){
		beki = Math.pow(i, p);
		if(beki > x){
		    break;
		}
	    }
	    if(max < Math.pow(i, p-1) && (p-1) != 1){
		max = Math.pow(i, p-1);
	    }
	    
	}

	System.out.println((int)max);
    }
} Main
import java.util.Scanner;

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

	int x = scan.nextInt();

        double max = 0;
	for(int i = 1; i <= x; i++){
	    double beki = 0;
	    int p;
	    for(p = 2; p < 10; p++){
		beki = Math.pow(i, p);
		if(beki > x){
		    break;
		}
	    }
	    if(max < Math.pow(i, p-1) && (p-1) != 1){
		max = Math.pow(i, p-1);
	    }
	    
	}

	System.out.println((int)max);
    }
}
