#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i)) #define rep(i,n) FOR(i,0,n) #define pb push_back #define eb emplace_back #define all(v) begin(v), end(v) #define debug(x) cerr<< #x <<": "< i_i; typedef pair p_i; typedef vector vi; typedef vector > vvi; typedef vector vll; typedef vector > vvll; typedef vector vc; typedef vector > vvc; typedef vector vd; typedef vector > vvd; template using vv=vector >; typedef deque di; typedef deque > ddi; // cout vector template ostream& operator<<(ostream& s, const vector& v) { int len = v.size(); for (int i = 0; i < len; ++i) { s << v[i]; if (i < len - 1) s << "\t"; } return s; } // cout 2-dimentional vector template ostream& operator<<(ostream& s, const vector< vector >& vv) { int len = vv.size(); for (int i = 0; i < len; ++i) { s << vv[i] << endl; } return s; } int MAX_PRIME; // in this problem up to 10^6 deque isprime; vector primes; void init_prime(int mp) { MAX_PRIME = mp; isprime.resize(MAX_PRIME+1, true); isprime[0] = isprime[1] = false; primes.clear(); for(int i = 2; i <= MAX_PRIME; i++) { if (isprime[i]) { primes.push_back(i); for(int j = i*2; j <= MAX_PRIME; j += i) { isprime[j] = false; } } } } ll min_factor(ll n) { rep (i, upper_bound(all(primes), (int)sqrt(n)) - begin(primes)) { if ( n % primes[i] == 0 ) { return primes[i]; } } return (ll)INT_MAX; } int main() { ll l, h; cin >> l >> h; init_prime(1000000); int maxminfact = 2; ll maxminproduct = h - (h % 2 == 1 ? 1 : 0); for (int i = upper_bound(all(primes), (int)sqrt(h)) - begin(primes) - 1; i >= 0; --i) { if ( primes[i] < maxminfact ) { break; } for (ll j = h / primes[i]; j * primes[i] >= l; --j) { int tmp_fact = min(primes[i], (int)min_factor(j)); if ( tmp_fact > maxminfact ) { maxminfact = tmp_fact; maxminproduct = j * primes[i]; } } } printf("%lld\n", maxminproduct); return 0; }