/* _ooOoo_ o8888888o 88" . "88 (| -_- |) O\ = /O ____/`---'\____ .' \\| |// `. / \\||| : |||// \ / _||||| -:- |||||- \ | | \\\ - /// | | | \_| ''\---/'' | | \ .-\__ `-` ___/-. / ___`. .' /--.--\ `. . __ ."" '< `.___\_<|>_/___.' >'"". | | : `- \`.;`\ _ /`;.`/ - ` : | | \ \ `-. \_ __\ /__ _/ .-` / / ======`-.____`-.___\_____/___.-`____.-'====== `=---=' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pass System Test! */ #include using namespace std; template std::ostream &operator<<(std::ostream &out, const std::vector &v) { if (!v.empty()) { out << '['; std::copy(v.begin(), v.end(), std::ostream_iterator(out, ", ")); out << "\b\b]"; } return out; } template std::ostream &operator<<(std::ostream &out, const std::pair &p) { out << "[" << p.first << ", " << p.second << "]"; return out; } template void chmin(T &t, U f) { if (t > f) t = f; } template void chmax(T &t, U f) { if (t < f) t = f; } template void uniq(vector &v) { v.erase(unique(v.begin(), v.end()), v.end()); } vector primes; void eratosthenes(int N) { vector is_prime(N + 1, true); is_prime[0] = false; is_prime[1] = false; for (int i = 2; i <= N; ++i) if (is_prime[i]) { primes.push_back(i); for (int j = i * 2; j <= N; j += i) { is_prime[j] = false; } } } int64_t get_min_divisor(int64_t t) { for (int p : primes) if (t % p == 0) return p; else if (p > sqrt(t + 1)) break; return t; } int main() { cin.tie(0); ios::sync_with_stdio(false); eratosthenes(1e5); int64_t L, H; cin >> L >> H; for (int i = primes.size() - 1; i >= 0; --i) { int64_t prime = primes[i]; int64_t h = H / prime * prime; int64_t l = max(L, prime * prime); for (; h >= l; h -= prime) { int64_t divisor = get_min_divisor(h / prime); if (divisor < prime) { continue; } cerr << prime << endl; cout << h << endl; return 0; } } }