def is_prime(N): i = 2 while i * i < N: if N % i == 0: return False i += 1 return True L, H = map(int, input().split()) nums = [i for i in range(L,H+1)] for n in nums: if is_prime(n): nums.remove(n) i = 2 while i * i < H: j = 0 while len(nums) > j: if len(nums) == 1: ans = nums[j] break if nums[j] % i == 0: nums.pop(j) continue j += 1 i += 1 print(ans)