import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc = new Scanner(System.in);
	int n;
	public void run(){
		n = sc.nextInt();
		solve();
	}
	public void solve(){
		int ans = 1;
		for(int i = 2; i <= n; i++){
			int check = i * i;
			if(check <= n){
				while(true){
					if(check * i > n){
						if(ans < check) ans = check;
						break;
					}
					check = check * i;
				}
			}
		}
		System.out.println(ans);
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
	static class Pair {
        int first,second;
        public Pair(int a,int b) {
            this.first = a;
            this.second = b;
        }
    }	
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util public class Main {
	Scanner sc = new Scanner(System.in);
	int n;
	public void run(){
		n = sc.nextInt();
		solve();
	}
	public void solve(){
		int ans = 1;
		for(int i = 2; i <= n; i++){
			int check = i * i;
			if(check <= n){
				while(true){
					if(check * i > n){
						if(ans < check) ans = check;
						break;
					}
					check = check * i;
				}
			}
		}
		System.out.println(ans);
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
	static class Pair {
        int first,second;
        public Pair(int a,int b) {
            this.first = a;
            this.second = b;
        }
    }	
} Main Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n; n public void run(){
		n = sc.nextInt();
		solve();
	} run {
		n = sc.nextInt();
		solve();
	} n = sc.nextInt() n sc.nextInt() sc.nextInt sc solve() solve public void solve(){
		int ans = 1;
		for(int i = 2; i <= n; i++){
			int check = i * i;
			if(check <= n){
				while(true){
					if(check * i > n){
						if(ans < check) ans = check;
						break;
					}
					check = check * i;
				}
			}
		}
		System.out.println(ans);
	} solve {
		int ans = 1;
		for(int i = 2; i <= n; i++){
			int check = i * i;
			if(check <= n){
				while(true){
					if(check * i > n){
						if(ans < check) ans = check;
						break;
					}
					check = check * i;
				}
			}
		}
		System.out.println(ans);
	} int ans = 1; ans 1 for(int i = 2; i <= n; i++){
			int check = i * i;
			if(check <= n){
				while(true){
					if(check * i > n){
						if(ans < check) ans = check;
						break;
					}
					check = check * i;
				}
			}
		} int i = 2; int i = 2; i 2 i <= n i n i++ i++ i {
			int check = i * i;
			if(check <= n){
				while(true){
					if(check * i > n){
						if(ans < check) ans = check;
						break;
					}
					check = check * i;
				}
			}
		} {
			int check = i * i;
			if(check <= n){
				while(true){
					if(check * i > n){
						if(ans < check) ans = check;
						break;
					}
					check = check * i;
				}
			}
		} int check = i * i; check i * i i i if(check <= n){
				while(true){
					if(check * i > n){
						if(ans < check) ans = check;
						break;
					}
					check = check * i;
				}
			} check <= n check n {
				while(true){
					if(check * i > n){
						if(ans < check) ans = check;
						break;
					}
					check = check * i;
				}
			} while(true){
					if(check * i > n){
						if(ans < check) ans = check;
						break;
					}
					check = check * i;
				} true {
					if(check * i > n){
						if(ans < check) ans = check;
						break;
					}
					check = check * i;
				} if(check * i > n){
						if(ans < check) ans = check;
						break;
					} check * i > n check * i check i n {
						if(ans < check) ans = check;
						break;
					} if(ans < check) ans = check; ans < check ans check ans = check ans check break; check = check * i check check * i check i System.out.println(ans) System.out.println System.out System System.out ans public static void main(String[] args){
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String[] args args static class Pair {
        int first,second;
        public Pair(int a,int b) {
            this.first = a;
            this.second = b;
        }
    } Pair int first first second; second public Pair(int a,int b) {
            this.first = a;
            this.second = b;
        } Pair {
            this.first = a;
            this.second = b;
        } this.first = a this.first this this.first a this.second = b this.second this this.second b int a a int b b public class Main {
	Scanner sc = new Scanner(System.in);
	int n;
	public void run(){
		n = sc.nextInt();
		solve();
	}
	public void solve(){
		int ans = 1;
		for(int i = 2; i <= n; i++){
			int check = i * i;
			if(check <= n){
				while(true){
					if(check * i > n){
						if(ans < check) ans = check;
						break;
					}
					check = check * i;
				}
			}
		}
		System.out.println(ans);
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
	static class Pair {
        int first,second;
        public Pair(int a,int b) {
            this.first = a;
            this.second = b;
        }
    }	
} public class Main {
	Scanner sc = new Scanner(System.in);
	int n;
	public void run(){
		n = sc.nextInt();
		solve();
	}
	public void solve(){
		int ans = 1;
		for(int i = 2; i <= n; i++){
			int check = i * i;
			if(check <= n){
				while(true){
					if(check * i > n){
						if(ans < check) ans = check;
						break;
					}
					check = check * i;
				}
			}
		}
		System.out.println(ans);
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
	static class Pair {
        int first,second;
        public Pair(int a,int b) {
            this.first = a;
            this.second = b;
        }
    }	
} Main
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc = new Scanner(System.in);
	int n;
	public void run(){
		n = sc.nextInt();
		solve();
	}
	public void solve(){
		int ans = 1;
		for(int i = 2; i <= n; i++){
			int check = i * i;
			if(check <= n){
				while(true){
					if(check * i > n){
						if(ans < check) ans = check;
						break;
					}
					check = check * i;
				}
			}
		}
		System.out.println(ans);
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
	static class Pair {
        int first,second;
        public Pair(int a,int b) {
            this.first = a;
            this.second = b;
        }
    }	
}
