L,R = [int(zz) for zz in input().split()]



Lm = L%2019

Rm = R%2019



if Lm*Rm == 0 or R-L > 2017 or Rm <= Lm:

    print((0))

    exit()



ans = 2019

for i in range(Lm,Rm+1):

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

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

print(ans)

L,R = [int(zz) for zz in input().split()]



if R-L >= 2018:

    print((0))

else:

    ans = 2019

    for i in range(L,R):

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

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

    print(ans)

L, R = [int(zz) for zz in input().split()]
Lm = L % 2019
Rm = R % 2019
if Lm * Rm == 0 or R - L > 2017 or Rm <= Lm:
    print((0))
    exit()
ans = 2019
for i in range(Lm, Rm + 1):
    for j in range(i + 1, Rm + 1):
        ans = min(ans, i * j % 2019)
print(ans)

L, R = [int(zz) for zz in input().split()]
if R - L >= 2018:
    print((0))
else:
    ans = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans = min(ans, i * j % 2019)
    print(ans)

-Lm = L % 2019 -Rm = R % 2019 -if Lm * Rm == 0 or R - L > 2017 or Rm <= Lm: +if R - L >= 2018: -    exit() -ans = 2019 -for i in range(Lm, Rm + 1): -    for j in range(i + 1, Rm + 1): -        ans = min(ans, i * j % 2019) -print(ans) +else: +    ans = 2019 +    for i in range(L, R): +        for j in range(i + 1, R + 1): +            ans = min(ans, i * j % 2019) +    print(ans)