from math import sqrt L,H = map(int,raw_input().split()) comp = set() ub = int(sqrt(H))+1 ans = 4 for p in xrange(2,ub): if p in comp: continue for c in xrange(p*2,H+1,p): if c in comp: continue comp.add(c) if c >= L: ans = c print ans