import math L,H=map(int,raw_input().split()) upperBound = 100001 isPrime=[True for i in range((upperBound-3)/2+1)] for i in range((int(math.sqrt(upperBound-3))-3)/2+1): # k*k = (2i+3)^2 <= upperBound-3 if isPrime[i]: k = i+i+3 # this is prime number # false out non_prime number from k*k # k*k = 4i^2+12i+9 = 2*(2i^2+6i+3)+3 # k*(k+1) = 2*(2i^2+6i+3)+3 + 2i+3 ... even number. skip # k*(k+2) = 2*(2i^2+6i+3+k)+3 non_prime = k*(i+1)+i for j in range(non_prime,(upperBound-3)/2+1,k): isPrime[j]=False primes = [2] + [i+i+3 for i in range((upperBound-3)/2+1) if isPrime[i]==True] primes.reverse() for i,p in enumerate(primes): if H/p <= 1: continue for c in range((H/p)*p, L-1, -p): ok = True for j in range(i+1,len(primes)): q=primes[j] if c%q==0: ok=False break if ok: print c exit()