#include #include #include #include using namespace std; vector getPrimes(int n) { vector ok(n, true); ok[0] = ok[1]= false; vector ret; for (int i = 2; i < n; i++) { if (!ok[i]) continue; ret.push_back(i); for (int j = i; j < n; j += i) ok[j] = false; } return ret; } long long fac(long long x) { for (long long d = 2; d * d <= x; d++) { if (x % d == 0) return d; } return x; } int main(int argc, char *argv[]) { long long l, h; cin >> l >> h; pair ret = make_pair(0, 0); vector ps = getPrimes(1e6); for (int i = ps.size()-1; i >= 0; i--) { if (ps[i] < ret.first) break; long long x = h / ps[i] * ps[i]; while (l <= x) { long long d = min(ps[i], fac(x/ps[i])); ret = max(ret, make_pair(d, x)); x -= ps[i]; } } cout << ret.second << endl; return 0; }