a, b = list(map(int, input().split()))

c = 2019



if b - a >= 2019:

    print((0))

else:

    for i in range(a, b):

        for j in range(a + 1 , b + 1):

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

    print(c)

a, b = list(map(int, input().split()))

c = 2019

for i in range(a, b):

    for j in range(a + 1 , b + 1):

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

        if c == 0:

            print(c)

            exit()

print(c)

a, b = list(map(int, input().split()))
c = 2019
if b - a >= 2019:
    print((0))
else:
    for i in range(a, b):
        for j in range(a + 1, b + 1):
            c = min(c, i * j % 2019)
    print(c)

a, b = list(map(int, input().split()))
c = 2019
for i in range(a, b):
    for j in range(a + 1, b + 1):
        c = min(c, i * j % 2019)
        if c == 0:
            print(c)
            exit()
print(c)

-if b - a >= 2019: -    print((0)) -else: -    for i in range(a, b): -        for j in range(a + 1, b + 1): -            c = min(c, i * j % 2019) -    print(c) +for i in range(a, b): +    for j in range(a + 1, b + 1): +        c = min(c, i * j % 2019) +        if c == 0: +            print(c) +            exit() +print(c)