def primes2(limit): ''' returns a list of prime numbers upto limit. source: Rossetta code: Sieve of Eratosthenes http://rosettacode.org/wiki/Sieve_of_Eratosthenes#Odds-only_version_of_the_array_sieve_above ''' if limit < 2: return [] if limit < 3: return [2] lmtbf = (limit - 3) // 2 buf = [True] * (lmtbf + 1) for i in range((int(limit ** 0.5) - 3) // 2 + 1): if buf[i]: p = i + i + 3 s = p * (i + 1) + i buf[s::p] = [False] * ((lmtbf - s) // p + 1) return [2] + [i + i + 3 for i, v in enumerate(buf) if v] def solve(L, H): maxp = int(H**0.5) ps = primes2(maxp) for p in ps[::-1]: pp = find_pseudo_prime(p, L, H, ps) if pp: return pp def find_pseudo_prime(p, L, H, ps): lower = L//p + (1 if L%p else 0) for q in range(H//p, lower - 1, -1): for r in ps: if r >= p: return p * q if q % r == 0: break return 0 L, H = map(int, input().split()) print(solve(L, H))