#include "bits/stdc++.h" using namespace std; #define rt return #define FOR(i,j,k) for(int i=j; i<(int)k;++i) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define mt make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; vector sieve(int n){ vector f(n+1); for(int i=3; i<=n; i+=2) f[i] = 1; for(int i=3; i<=sqrt(n); i+=2) if(f[i]) for(int j=i*3; j<=n; j+=i) f[j] = 0; vector res{2}; for(int i=3; i<=n; i+=2) if(f[i]) res.push_back(i); return res; } typedef ll Num; bool isPrime(Num n){ if(n==1) return 0; for(Num i=2; i*i<=n; ++i) if(n%i==0) return 0; return 1; } ll L, H; #define LIM 300 int main(){ ios::sync_with_stdio(0); cin.tie(0); while(cin >> L >> H){ auto ps = sieve(100000); pair ans(-1, -1); if(H - L <= LIM){ for(ll i = L; i <= H; ++i)if(!isPrime(i)){ for(ll j = 2; j*j <= i; ++j){ if(i%j == 0){ smax(ans, mp((int)j, i)); break; } } } } else{ while(ps.back()*2ll > H)ps.pop_back(); auto ps2 = ps; for(int i = sz(ps) - 1; i >= 0;--i){ while(sz(ps2) && (ll)ps[i] * ps[i] * ps2.back())ps2.pop_back(); FOR(j, i, sz(ps)){ ll val = (ll)ps[i] * ps[j]; if(val <= H && val >= L)smax(ans, mp(ps[i], val)); if(val > H)break; if(j >= sz(ps2))continue; ll q = H / val; auto it = lower_bound(ps2.begin()+j, ps2.end(), q); if(*it*ps[i] * ps[j] > H && it != ps2.begin())--it; ll val2 = *it*ps[i] * ps[j]; if(*it >= ps[j] && val2 >= L && val2 <= H) smax(ans, mp(ps[i], val2)); } if(ans.first != -1)break; } /* rep(i, sz(ps))FOR(j, i, sz(ps)){ ll val = (ll)ps[i] * ps[j]; if(val > H)break; if(val >= L) smax(ans, mp(ps[i], val)); FOR(k, j, sz(ps)){ ll val2 = val*ps[k]; if(val2 > H)break; if(val2 >= L)smax(ans, mp(ps[i], val2)); FOR(l, k, sz(ps)){ ll val3 = val2*ps[l]; if(val3 > H)break; if(val3 >= L)smax(ans, mp(ps[i], val3)); } } }*/ } cout << ans.second << endl; } }