import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto rd = readln.split.to!(long[]), l = rd[0], h = rd[1]; auto p = primes(h.nsqrt).to!(long[]); auto a = p.map!"a * a".assumeSorted!"a <= b".lowerBound(h).back; auto ra = a.nsqrt; if (a >= l) { auto r = a; for (auto b = ra+1; b*ra <= h; ++b) if (factor(b, p) > ra) r = b*ra; writeln(r); } else { auto r = 0L, mf = 0L; foreach (b; l..h+1) { auto f = factor(b, p); if (f != b && f >= mf) { mf = f; r = b; } } writeln(r); } } pure T[] primes(T)(T n) { import std.algorithm, std.bitmanip, std.conv, std.range; auto sieve = BitArray(); sieve.length((n + 1) / 2); sieve = ~sieve; foreach (p; 1..((nsqrt(n) - 1) / 2 + 1)) if (sieve[p]) for (auto q = p * 3 + 1; q < (n + 1) / 2; q += p * 2 + 1) sieve[q] = false; auto r = sieve.bitsSet.map!(to!T).map!("a * 2 + 1").array; r[0] = 2; return r; } pure T factor(T)(T n, const T[] pi) { auto ma = nsqrt(n) + 1; foreach (p; pi) if (p > ma) return n; else if (n % p == 0) return p; return n; } pure T nsqrt(T)(T n) { import std.algorithm, std.conv, std.range, core.bitop; if (n <= 1) return n; T m = 1 << (n.bsr / 2 + 1); return iota(1, m).map!"a * a".assumeSorted!"a <= b".lowerBound(n).length.to!T; }