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

modL = L % 2019

modR = R % 2019

min2019 = 2019



if R - L >= 2018:

    print((0))

else:

    for j in range(modL, modR+1):

        for k in range(j+1 , modR+1):

            min2019 = min(min2019, j * k % 2019)

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



modL = L % 2019

modR = R % 2019

min2019 = 2019



if R - L >= 2018:

    print((0))

elif modL <=3 and modR >=673:

    print((0))

else:

    for j in range(modL, modR+1):

        for k in range(j+1, modR+1):

            min2019 = min(min2019, j * k % 2019)

    print(min2019)

L, R = list(map(int, input().split()))
modL = L % 2019
modR = R % 2019
min2019 = 2019
if R - L >= 2018:
    print((0))
else:
    for j in range(modL, modR + 1):
        for k in range(j + 1, modR + 1):
            min2019 = min(min2019, j * k % 2019)
    print(min2019)

L, R = list(map(int, input().split()))
modL = L % 2019
modR = R % 2019
min2019 = 2019
if R - L >= 2018:
    print((0))
elif modL <= 3 and modR >= 673:
    print((0))
else:
    for j in range(modL, modR + 1):
        for k in range(j + 1, modR + 1):
            min2019 = min(min2019, j * k % 2019)
    print(min2019)

+elif modL <= 3 and modR >= 673: +    print((0))