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

ans = 2018

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

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

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

print(ans)

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

ans = 2018

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

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

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

print(ans)

L, R = list(map(int, input().split()))
ans = 2018
for i in range(L, min(R, L + 2019) + 1):
    for j in range(i + 1, min(R, L + 2019) + 1):
        ans = min(ans, ((i % 2019) * (j % 2019)) % 2019)
print(ans)

L, R = list(map(int, input().split()))
ans = 2018
for i in range(L, min(L + 2019, R) + 1):
    for j in range(i + 1, min(L + 2019, R) + 1):
        ans = min(ans, (i * j) % 2019)
print(ans)

-for i in range(L, min(R, L + 2019) + 1): -    for j in range(i + 1, min(R, L + 2019) + 1): -        ans = min(ans, ((i % 2019) * (j % 2019)) % 2019) +for i in range(L, min(L + 2019, R) + 1): +    for j in range(i + 1, min(L + 2019, R) + 1): +        ans = min(ans, (i * j) % 2019)