L,R=list(map(int,input().split()))

l1=L//2019

r1=R//2019

if l1<r1:

  print((0))

elif l1==r1:

  res=[]

  for i in range(L,R+1):

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

      res.append((i*j)%2019)

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

mod=2019

a=l%mod

b=l//mod

c=r%mod

d=r//mod

if d-b!=0:

  print((0))

else:

  ans=float('inf')

  for i in range(l,r):

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

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

  print(ans)
L, R = list(map(int, input().split()))
l1 = L // 2019
r1 = R // 2019
if l1 < r1:
    print((0))
elif l1 == r1:
    res = []
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            res.append((i * j) % 2019)
    print((min(res)))

l, r = list(map(int, input().split()))
mod = 2019
a = l % mod
b = l // mod
c = r % mod
d = r // mod
if d - b != 0:
    print((0))
else:
    ans = float("inf")
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            ans = min(ans, (i * j) % mod)
    print(ans)

-L, R = list(map(int, input().split())) -l1 = L // 2019 -r1 = R // 2019 -if l1 < r1: +l, r = list(map(int, input().split())) +mod = 2019 +a = l % mod +b = l // mod +c = r % mod +d = r // mod +if d - b != 0: -elif l1 == r1: -    res = [] -    for i in range(L, R + 1): -        for j in range(i + 1, R + 1): -            res.append((i * j) % 2019) -    print((min(res))) +else: +    ans = float("inf") +    for i in range(l, r): +        for j in range(i + 1, r + 1): +            ans = min(ans, (i * j) % mod) +    print(ans)