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



new_L = L % 2019

new_R = R % 2019





if R - L >= 2019:

    print((0))

else:

    mi=10**10

    for l in range(new_L,new_R+1):

        for r in range(l+1,new_R+1):

            mod = (l*r) % 2019

            if mod < mi:

                mi=mod

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



import sys



mi=10**10

for l in range(L,R+1):

    for r in range(l+1,R+1):

        mod = (l*r) % 2019

        if mod < mi:

            mi=mod

        if mi==0:

            print(mi)

            sys.exit()

print(mi)
L, R = list(map(int, input().split()))
new_L = L % 2019
new_R = R % 2019
if R - L >= 2019:
    print((0))
else:
    mi = 10**10
    for l in range(new_L, new_R + 1):
        for r in range(l + 1, new_R + 1):
            mod = (l * r) % 2019
            if mod < mi:
                mi = mod
    print(mi)

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

mi = 10**10
for l in range(L, R + 1):
    for r in range(l + 1, R + 1):
        mod = (l * r) % 2019
        if mod < mi:
            mi = mod
        if mi == 0:
            print(mi)
            sys.exit()
print(mi)

-new_L = L % 2019 -new_R = R % 2019 -if R - L >= 2019: -    print((0)) -else: -    mi = 10**10 -    for l in range(new_L, new_R + 1): -        for r in range(l + 1, new_R + 1): -            mod = (l * r) % 2019 -            if mod < mi: -                mi = mod -    print(mi) +import sys + +mi = 10**10 +for l in range(L, R + 1): +    for r in range(l + 1, R + 1): +        mod = (l * r) % 2019 +        if mod < mi: +            mi = mod +        if mi == 0: +            print(mi) +            sys.exit() +print(mi)