inf = float('inf')



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



if R > L + 3000:

    R = L + 3000

t = [i % 2019 for i in range(L, R + 1)]

t.sort()

if (3 in t and 673 in t) or (0 in t):

    print((0))

else:

    n = len(t)

    ans = inf

    for i in range(n - 1):

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

            ans = min(ans, t[i] * t[j] % 2019)

    print(ans)

    # print(t)

mod = 2019

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

e = []

for i in range(l, min(r, l + mod * 2) + 1):

    e.append(i % mod)

e.sort()



ans = mod

for i in range(len(e)):

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

        ans = min(ans, e[i] * e[j] % mod)

        if ans == 0:

            break

    else:

        continue

    break

print(ans)

inf = float("inf")
L, R = list(map(int, input().split()))
if R > L + 3000:
    R = L + 3000
t = [i % 2019 for i in range(L, R + 1)]
t.sort()
if (3 in t and 673 in t) or (0 in t):
    print((0))
else:
    n = len(t)
    ans = inf
    for i in range(n - 1):
        for j in range(i + 1, n):
            ans = min(ans, t[i] * t[j] % 2019)
    print(ans)
    # print(t)

mod = 2019
l, r = list(map(int, input().split()))
e = []
for i in range(l, min(r, l + mod * 2) + 1):
    e.append(i % mod)
e.sort()
ans = mod
for i in range(len(e)):
    for j in range(i + 1, len(e)):
        ans = min(ans, e[i] * e[j] % mod)
        if ans == 0:
            break
    else:
        continue
    break
print(ans)

-inf = float("inf") -L, R = list(map(int, input().split())) -if R > L + 3000: -    R = L + 3000 -t = [i % 2019 for i in range(L, R + 1)] -t.sort() -if (3 in t and 673 in t) or (0 in t): -    print((0)) -else: -    n = len(t) -    ans = inf -    for i in range(n - 1): -        for j in range(i + 1, n): -            ans = min(ans, t[i] * t[j] % 2019) -    print(ans) -    # print(t) +mod = 2019 +l, r = list(map(int, input().split())) +e = [] +for i in range(l, min(r, l + mod * 2) + 1): +    e.append(i % mod) +e.sort() +ans = mod +for i in range(len(e)): +    for j in range(i + 1, len(e)): +        ans = min(ans, e[i] * e[j] % mod) +        if ans == 0: +            break +    else: +        continue +    break +print(ans)