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

MOD = 2019



ans = MOD

for l in range(L,L+MOD+2):

    for r in reversed(list(range(R-MOD-2,R+1))):

        if l>=r: break

        ans = min(ans, (l*r)%MOD)

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

if R-L >= 2019:

    print((0))

    exit()



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 = list(map(int, input().split()))
MOD = 2019
ans = MOD
for l in range(L, L + MOD + 2):
    for r in reversed(list(range(R - MOD - 2, R + 1))):
        if l >= r:
            break
        ans = min(ans, (l * r) % MOD)
print(ans)

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

-MOD = 2019 -ans = MOD -for l in range(L, L + MOD + 2): -    for r in reversed(list(range(R - MOD - 2, R + 1))): -        if l >= r: -            break -        ans = min(ans, (l * r) % MOD) +if R - L >= 2019: +    print((0)) +    exit() +ans = 2019 +for i in range(L, R): +    for j in range(i + 1, R + 1): +        ans = min(ans, (i * j) % 2019)