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



if R-L >= 2019:

    print((0))

    exit()



flag = True

ans = 2020



for i in range(L, L+2018):

    if flag:

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

            if i > R:

                flag = False

                break

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



print(ans)

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

ans = 2019

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

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

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

print(ans)

L, R = list(map(int, input().split()))
if R - L >= 2019:
    print((0))
    exit()
flag = True
ans = 2020
for i in range(L, L + 2018):
    if flag:
        for j in range(i + 1, R + 1):
            if i > R:
                flag = False
                break
            ans = min(((i % 2019) * (j % 2019)) % 2019, ans)
print(ans)

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

-if R - L >= 2019: -    print((0)) -    exit() -flag = True -ans = 2020 -for i in range(L, L + 2018): -    if flag: -        for j in range(i + 1, R + 1): -            if i > R: -                flag = False -                break -            ans = min(((i % 2019) * (j % 2019)) % 2019, ans) +ans = 2019 +for i in range(L, min(R + 1, L + 2019)): +    for j in range(i + 1, min(R + 1, L + 2019)): +        ans = min(ans, (i * j) % 2019)