#include #include #include #include using namespace std; vector getPrimes(int n) { vector isPrime(n+1, true); isPrime[0] = isPrime[1] = false; for (int i = 2; i * i <= n; i++) { if (!isPrime[i]) continue; for (int j = i * i; j <= n; j += i) isPrime[j] = false; } int m = 0; for (int i = 0; i <= n; i++) if (isPrime[i]) ++m; int pos = 0; vector ret(m); for (int i = 0; i <= n; i++) if (isPrime[i]) ret[pos++] = i; return ret; } map factorize(long long n) { map ret; for (long long i = 2; i * i <= n; i++) { while (n % i == 0) { ++ret[i]; n /= i; } } if (n != 1) ret[n] = 1; return ret; } int minFac(long long n) { map facs = factorize(n); long long ret = facs.begin()->first; if (ret == n) return 1; return (int)ret; } int main(int argc, char *argv[]) { long long l, h; cin >> l >> h; vector pr = getPrimes(1e3); int n = pr.size(); pair ret = make_pair(0, 0); for (int i = n-1; i >= 0; i--) { for (int j = i; j < n; j++) { long long x = pr[i] * pr[j]; if (l <= x && x <= h) { ret = max(ret, make_pair(pr[i], x)); } } if (ret.first) break; } if (!ret.first) { // this block is executed only if abs(h-l) is enough small. for (long long i = l; i <= h; i++) { ret = max(ret, make_pair(minFac(i), i)); } } cout << ret.second << endl; return 0; }