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 = a * b

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

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

        if i != j:

            if c > i * j % 2019:

                c = i * j % 2019

            if c == 0:

                print((0))

                exit()

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 = a * b
for i in range(a, b + 1):
    for j in range(a, b + 1):
        if i != j:
            if c > i * j % 2019:
                c = i * j % 2019
            if c == 0:
                print((0))
                exit()
print(c)

-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() +c = a * b +for i in range(a, b + 1): +    for j in range(a, b + 1): +        if i != j: +            if c > i * j % 2019: +                c = i * j % 2019 +            if c == 0: +                print((0)) +                exit()