#include using namespace std; typedef long long ll; typedef vector vi; typedef vector vl; typedef complex P; typedef pair pii; #define REP(i,n) for(ll i=0;i>=1; } return r; } int main(){ scanf("%lld%lld",&L,&H); REP(i,100000)isp[i]=true; isp[0]=isp[1]=false; FOR(x,2,100000){ if(!isp[x])continue; ps.push_back(x); { int it = x+x; while(it<100000){ isp[it]=false; it+=x; } } } if(H-L<50000){ // brute-force ll mx = L-1; ll mfct = 0; FOR(x,L,H+1){ REP(i,ps.size()){ ll p = ps[i]; if(x<=p)break; if(x%p==0){ if(p>=mfct){ mfct = p; mx = x; } break; } } } printf("%lld\n",mx); }else{ set dp; dp.insert(1); FOR(i,0,ps.size()){ ll x = ps[ps.size()-1-i]; ll ans = -1; for(ll p : dp){ if(p*x>H)break; dp.insert(p*x); if(p!=1 && L<=p*x){ ans = max(ans,p*x); } } if(ans!=-1){ printf("%lld\n",ans); return 0; } } } return 0; }