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

x, y = L % 2019, R % 2019

if (R-L) > 2017 or x>=y:

    print((0))

else:

    m = 2019

    for i in range(x, y + 1):

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

           x = (i * j) % 2019

           m = min(m, x)

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

x, y = L % 2019, R % 2019

if (R-L) > 2017 or x>=y:

    print((0))

else:

    m = 2019

    for i in range(x, y + 1):

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

           x = (i * j) % 2019

           m = min(m, x)

           if m == 0:

               break

        if m == 0:

            break

    print(m)
L, R = list(map(int, input().split()))
x, y = L % 2019, R % 2019
if (R - L) > 2017 or x >= y:
    print((0))
else:
    m = 2019
    for i in range(x, y + 1):
        for j in range(i + 1, y + 1):
            x = (i * j) % 2019
            m = min(m, x)
    print(m)

L, R = list(map(int, input().split()))
x, y = L % 2019, R % 2019
if (R - L) > 2017 or x >= y:
    print((0))
else:
    m = 2019
    for i in range(x, y + 1):
        for j in range(i + 1, y + 1):
            x = (i * j) % 2019
            m = min(m, x)
            if m == 0:
                break
        if m == 0:
            break
    print(m)

+            if m == 0: +                break +        if m == 0: +            break