#include #define rep(i, a, n) for(int i = a; i < n; i++) #define repp(i, n) rep(i, 0, n) #define repb(i, a, b) for(int i = a; i >= b; i--) #define all(a) a.begin(), a.end() #define int long long using namespace std; vector prime; bool isprime[100010]; void sieve(int n){ rep(i, 0, n + 1) isprime[i] = true; isprime[0] = isprime[1] = false; rep(i, 2, n + 1){ if(isprime[i]) prime. push_back(i); for(int j = 2*i; j <= n; j += i) isprime[j] = false; } return; } signed main(){ int l, h, a, ans = -1; cin >> l >> h; sieve(100000); a = prime.back(); if(h - l >= a){ rep(i, 0, 200000){ if(i*a > h){ ans = a*(i - 1); break; } } }else{ vector cand; bool f[100010]; memset(f, true, sizeof(f)); rep(i, 0, prime.size()){ int st = (l - 1) / prime[i] + 1; for(int j = st*prime[i]; j <= h; j += prime[i]){ if(j != prime[i] && f[j - l] == true) cand. push_back(j); f[j - l] = false; } } ans = cand.back(); } cout << ans << endl; }