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

if r - l >2017:

    print((0))

else:

    ij = []

    for i in range(l, r):

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

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

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

 

if R - L >= 2017:

  print((0))

  exit()

 

ans_list = []

 

for x in range(L, R):

  for y in range(x+1, R+1):   

    ans_list.append((x * y) % 2019)

    

print((min(ans_list)))
l, r = list(map(int, input().split()))
if r - l > 2017:
    print((0))
else:
    ij = []
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            ij.append((i * j) % 2019)
    print((min(ij)))

L, R = list(map(int, input().split()))
if R - L >= 2017:
    print((0))
    exit()
ans_list = []
for x in range(L, R):
    for y in range(x + 1, R + 1):
        ans_list.append((x * y) % 2019)
print((min(ans_list)))

-l, r = list(map(int, input().split())) -if r - l > 2017: +L, R = list(map(int, input().split())) +if R - L >= 2017: -else: -    ij = [] -    for i in range(l, r): -        for j in range(i + 1, r + 1): -            ij.append((i * j) % 2019) -    print((min(ij))) +    exit() +ans_list = [] +for x in range(L, R): +    for y in range(x + 1, R + 1): +        ans_list.append((x * y) % 2019) +print((min(ans_list)))