#include using namespace std; struct INIT{INIT(){ios::sync_with_stdio(false);cin.tie(0);}}init; typedef long long LL; vector prime; struct eratosthenes{ eratosthenes(){ vector used(110001,true); for(int i = 2; i*i <= 110000; i++){ if(used[i]){ for(int j = i+i; j <= 110000; j+=i) used[j]=false; } } for(int i = 2; i <= 110000; i++){ if(used[i])prime.push_back(i); } } }e; int main() { LL L,H; cin >> L >> H; LL b=0; for(; prime[b]*prime[b] <= H; b++); b--; LL c=b; for(; prime[b]*prime[c] <= H; c++); c--; L=max(L,prime[b]*prime[c]); int sz=H-L+1; vector> res(sz,pair(114514,0)); for(int i = 0; i < sz; i++) res[i].second=L+i; for(auto& p : prime){ LL d=(L+p-1)/p; d=d*p-L; for(int i = d;i < sz; i+=p) if(res[i].second!=p) res[i].first=min(res[i].first,p); } pair ans; for(auto& it : res){ if(it.first!=114514)ans=max(ans,it); } cout << ans.second << endl; return 0; }