#include using namespace std; typedef long long int64; int64 prime_factor(int64 n, vector< int >& is) { for(int64 i : is) { if(i * i > n) break; if(n % i == 0) return(i); } return(-1); } vector< int > get_prime(int n) { vector< bool > prime( n + 1, true); if(n >= 0) prime[0] = false; if(n >= 1) prime[1] = false; for(int i = 2; i * i <= n; i++){ if(prime[i]){ for(int j = i + i; j <= n; j += i) prime[j] = false; } } vector< int > primes; for(int i = 2; i <= n; i++) { if(prime[i]) primes.push_back(i); } return(primes); } int main() { vector< int > prime = get_prime(100000); reverse(prime.begin(), prime.end()); int64 L, H; cin >> L >> H; for(int64 i : prime) { if(L <= i * i && i * i <= H) { for(int64 j : prime) { if(L <= i * j && i * j <= H) { cout << i * j << endl; exit(0); } } } } reverse(prime.begin(), prime.end()); pair< int64, int64 > ret(2, 2); for(int64 i = L; i <= H; i++) { ret = max(ret, {prime_factor(i, prime), i}); } cout << ret.second << endl; }