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 = 10 ** 9

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

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

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