import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		sc.close();
		int[] Array = new int[1000];
		Arrays.fill(Array,0);
		int max = 1;
		if(X <= 3) {
			System.out.println(1);
		}
		else {
			for (int i = 2; i <= X; i++) {
				int num = i * i;
				while (num <= X) {
					max = Math.max(max, num);
					num *= i;
				}
			}
			System.out.println(max);
		}	
	}
} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		sc.close();
		int[] Array = new int[1000];
		Arrays.fill(Array,0);
		int max = 1;
		if(X <= 3) {
			System.out.println(1);
		}
		else {
			for (int i = 2; i <= X; i++) {
				int num = i * i;
				while (num <= X) {
					max = Math.max(max, num);
					num *= i;
				}
			}
			System.out.println(max);
		}	
	}
} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		sc.close();
		int[] Array = new int[1000];
		Arrays.fill(Array,0);
		int max = 1;
		if(X <= 3) {
			System.out.println(1);
		}
		else {
			for (int i = 2; i <= X; i++) {
				int num = i * i;
				while (num <= X) {
					max = Math.max(max, num);
					num *= i;
				}
			}
			System.out.println(max);
		}	
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		sc.close();
		int[] Array = new int[1000];
		Arrays.fill(Array,0);
		int max = 1;
		if(X <= 3) {
			System.out.println(1);
		}
		else {
			for (int i = 2; i <= X; i++) {
				int num = i * i;
				while (num <= X) {
					max = Math.max(max, num);
					num *= i;
				}
			}
			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 sc.close() sc.close sc int[] Array = new int[1000]; Array new int[1000] 1000 Arrays.fill(Array,0) Arrays.fill Arrays Array 0 int max = 1; max 1 if(X <= 3) {
			System.out.println(1);
		}
		else {
			for (int i = 2; i <= X; i++) {
				int num = i * i;
				while (num <= X) {
					max = Math.max(max, num);
					num *= i;
				}
			}
			System.out.println(max);
		} X <= 3 X 3 {
			System.out.println(1);
		} System.out.println(1) System.out.println System.out System System.out 1 {
			for (int i = 2; i <= X; i++) {
				int num = i * i;
				while (num <= X) {
					max = Math.max(max, num);
					num *= i;
				}
			}
			System.out.println(max);
		} for (int i = 2; i <= X; i++) {
				int num = i * i;
				while (num <= X) {
					max = Math.max(max, num);
					num *= i;
				}
			} int i = 2; int i = 2; i 2 i <= X i X i++ i++ i {
				int num = i * i;
				while (num <= X) {
					max = Math.max(max, num);
					num *= i;
				}
			} {
				int num = i * i;
				while (num <= X) {
					max = Math.max(max, num);
					num *= i;
				}
			} int num = i * i; num i * i i i while (num <= X) {
					max = Math.max(max, num);
					num *= i;
				} num <= X num X {
					max = Math.max(max, num);
					num *= i;
				} max = Math.max(max, num) max Math.max(max, num) Math.max Math max num num *= i num i 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) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		sc.close();
		int[] Array = new int[1000];
		Arrays.fill(Array,0);
		int max = 1;
		if(X <= 3) {
			System.out.println(1);
		}
		else {
			for (int i = 2; i <= X; i++) {
				int num = i * i;
				while (num <= X) {
					max = Math.max(max, num);
					num *= i;
				}
			}
			System.out.println(max);
		}	
	}
} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		sc.close();
		int[] Array = new int[1000];
		Arrays.fill(Array,0);
		int max = 1;
		if(X <= 3) {
			System.out.println(1);
		}
		else {
			for (int i = 2; i <= X; i++) {
				int num = i * i;
				while (num <= X) {
					max = Math.max(max, num);
					num *= i;
				}
			}
			System.out.println(max);
		}	
	}
} Main
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		sc.close();
		int[] Array = new int[1000];
		Arrays.fill(Array,0);
		int max = 1;
		if(X <= 3) {
			System.out.println(1);
		}
		else {
			for (int i = 2; i <= X; i++) {
				int num = i * i;
				while (num <= X) {
					max = Math.max(max, num);
					num *= i;
				}
			}
			System.out.println(max);
		}	
	}
}