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

mod = 2019

frem = []

srem = []

if r - l + 1 >= 2019:

    ans = 0

else:

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

        frem.append(i % mod)

    for i in range(len(frem)):

        for j in range(i+1, len(frem)):

            # print(frem[i], frem[j])

            srem.append(frem[i]*frem[j] % mod)

    srem.sort()

    ans = srem[0]



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

mod = 2019

frem = []

srem = []

if r - l + 1 >= 2019:

    ans = 0

else:

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

        frem.append(i % mod)

    for i in range(len(frem)):

        for j in range(i+1, len(frem)):

            # print(frem[i], frem[j])

            srem.append(frem[i]*frem[j] % mod)

    # srem.sort()

    ans = min(srem)



print(ans)
l, r = list(map(int, input().split()))
mod = 2019
frem = []
srem = []
if r - l + 1 >= 2019:
    ans = 0
else:
    for i in range(l, r + 1):
        frem.append(i % mod)
    for i in range(len(frem)):
        for j in range(i + 1, len(frem)):
            # print(frem[i], frem[j])
            srem.append(frem[i] * frem[j] % mod)
    srem.sort()
    ans = srem[0]
print(ans)

l, r = list(map(int, input().split()))
mod = 2019
frem = []
srem = []
if r - l + 1 >= 2019:
    ans = 0
else:
    for i in range(l, r + 1):
        frem.append(i % mod)
    for i in range(len(frem)):
        for j in range(i + 1, len(frem)):
            # print(frem[i], frem[j])
            srem.append(frem[i] * frem[j] % mod)
    # srem.sort()
    ans = min(srem)
print(ans)

-    srem.sort() -    ans = srem[0] +    # srem.sort() +    ans = min(srem)