l,r=list(map(int,input().split()));s=list(range(l,r+1));print((+(r-l<2019)and min(i*j%2019for i in s for j in s if i<j)))
l,r=list(map(int,input().split()));s=list(range(l,r+1));print((+(r-l<2e3)and min(i*j%2019for i in s for j in s if i<j)))
l, r = list(map(int, input().split()))
s = list(range(l, r + 1))
print((+(r - l < 2019) and min(i * j % 2019 for i in s for j in s if i < j)))

l, r = list(map(int, input().split()))
s = list(range(l, r + 1))
print((+(r - l < 2e3) and min(i * j % 2019 for i in s for j in s if i < j)))

-print((+(r - l < 2019) and min(i * j % 2019 for i in s for j in s if i < j))) +print((+(r - l < 2e3) and min(i * j % 2019 for i in s for j in s if i < j)))