l,r=list(map(int,input().split()))

s=list(range(l,r+1))[:2019]

print((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))[:673];print((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))[:2019]
print((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))[:673]
print((min(i * j % 2019 for i in s for j in s if i < j)))

-s = list(range(l, r + 1))[:2019] +s = list(range(l, r + 1))[:673]