def prime_table(n): table = [0 for _ in xrange(n+1)] i = 2 while i * i <= n: if table[i] == 0: j = i + i while j <= n: if table[j] == 0: table[j] = i j += i i += 1 return table L, H = map(int, raw_input().split()) pt = prime_table(10**5+1) mv, mi = 0, -1 for i in xrange(L, H+1): if pt[i] >= mv: mv = pt[i] mi = i print mi