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

if r-l>=2019:

  print((0))

  exit()

l = l%2019

r = r%2019

ans = 2018

for i in range(l,r):

  for j in range(l+1,r+1):

    ans = min(ans,i*j%2019)

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

if r-l>=2019:

  print((0))

  exit()

l = l%2019

r = r%2019

ans = 2018

for i in range(l,r):

  for j in range(i+1,r+1):

    ans = min(ans,i*j%2019)

print(ans)
l, r = list(map(int, input().split()))
if r - l >= 2019:
    print((0))
    exit()
l = l % 2019
r = r % 2019
ans = 2018
for i in range(l, r):
    for j in range(l + 1, r + 1):
        ans = min(ans, i * j % 2019)
print(ans)

l, r = list(map(int, input().split()))
if r - l >= 2019:
    print((0))
    exit()
l = l % 2019
r = r % 2019
ans = 2018
for i in range(l, r):
    for j in range(i + 1, r + 1):
        ans = min(ans, i * j % 2019)
print(ans)

-    for j in range(l + 1, r + 1): +    for j in range(i + 1, r + 1):