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

if r - l > 2030: print((0))

else:

    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 > 2030: print((0))

else:

    ans = 2018

    for i in range(l, r):

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

            ans_ = i*j%2019

            if ans_ < ans:

                ans = ans_

    print(ans)
l, r = list(map(int, input().split()))
if r - l > 2030:
    print((0))
else:
    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 > 2030:
    print((0))
else:
    ans = 2018
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            ans_ = i * j % 2019
            if ans_ < ans:
                ans = ans_
    print(ans)

-            ans = min(ans, i * j % 2019) +            ans_ = i * j % 2019 +            if ans_ < ans: +                ans = ans_