import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X= sc.nextInt();
		int answer = 1;
		if (X <= 3) {
			System.out.println("1");
		} else {
			for (int i = 2 ; i <= 31; i++) {
				int candidate = i;
				while ( candidate * i <= X) {
					candidate *= i ;
					answer = Math.max(answer, candidate);
			}

		}
			System.out.println(answer);
		}

}
} 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 answer = 1;
		if (X <= 3) {
			System.out.println("1");
		} else {
			for (int i = 2 ; i <= 31; i++) {
				int candidate = i;
				while ( candidate * i <= X) {
					candidate *= i ;
					answer = Math.max(answer, candidate);
			}

		}
			System.out.println(answer);
		}

}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X= sc.nextInt();
		int answer = 1;
		if (X <= 3) {
			System.out.println("1");
		} else {
			for (int i = 2 ; i <= 31; i++) {
				int candidate = i;
				while ( candidate * i <= X) {
					candidate *= i ;
					answer = Math.max(answer, candidate);
			}

		}
			System.out.println(answer);
		}

} main {
		Scanner sc = new Scanner(System.in);
		int X= sc.nextInt();
		int answer = 1;
		if (X <= 3) {
			System.out.println("1");
		} else {
			for (int i = 2 ; i <= 31; i++) {
				int candidate = i;
				while ( candidate * i <= X) {
					candidate *= i ;
					answer = Math.max(answer, candidate);
			}

		}
			System.out.println(answer);
		}

} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int X= sc.nextInt(); X sc.nextInt() sc.nextInt sc int answer = 1; answer 1 if (X <= 3) {
			System.out.println("1");
		} else {
			for (int i = 2 ; i <= 31; i++) {
				int candidate = i;
				while ( candidate * i <= X) {
					candidate *= i ;
					answer = Math.max(answer, candidate);
			}

		}
			System.out.println(answer);
		} 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 <= 31; i++) {
				int candidate = i;
				while ( candidate * i <= X) {
					candidate *= i ;
					answer = Math.max(answer, candidate);
			}

		}
			System.out.println(answer);
		} for (int i = 2 ; i <= 31; i++) {
				int candidate = i;
				while ( candidate * i <= X) {
					candidate *= i ;
					answer = Math.max(answer, candidate);
			}

		} int i = 2 ; int i = 2 ; i 2 i <= 31 i 31 i++ i++ i {
				int candidate = i;
				while ( candidate * i <= X) {
					candidate *= i ;
					answer = Math.max(answer, candidate);
			}

		} {
				int candidate = i;
				while ( candidate * i <= X) {
					candidate *= i ;
					answer = Math.max(answer, candidate);
			}

		} int candidate = i; candidate i while ( candidate * i <= X) {
					candidate *= i ;
					answer = Math.max(answer, candidate);
			} candidate * i <= X candidate * i candidate i X {
					candidate *= i ;
					answer = Math.max(answer, candidate);
			} candidate *= i candidate i answer = Math.max(answer, candidate) answer Math.max(answer, candidate) Math.max Math answer candidate System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X= sc.nextInt();
		int answer = 1;
		if (X <= 3) {
			System.out.println("1");
		} else {
			for (int i = 2 ; i <= 31; i++) {
				int candidate = i;
				while ( candidate * i <= X) {
					candidate *= i ;
					answer = Math.max(answer, candidate);
			}

		}
			System.out.println(answer);
		}

}
} public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X= sc.nextInt();
		int answer = 1;
		if (X <= 3) {
			System.out.println("1");
		} else {
			for (int i = 2 ; i <= 31; i++) {
				int candidate = i;
				while ( candidate * i <= X) {
					candidate *= i ;
					answer = Math.max(answer, candidate);
			}

		}
			System.out.println(answer);
		}

}
} 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 answer = 1;
		if (X <= 3) {
			System.out.println("1");
		} else {
			for (int i = 2 ; i <= 31; i++) {
				int candidate = i;
				while ( candidate * i <= X) {
					candidate *= i ;
					answer = Math.max(answer, candidate);
			}

		}
			System.out.println(answer);
		}

}
}