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



if R - L >= 2018:

    print((0))

else:

    min_value = 2018

    for i in range(L, R):

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

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

    print(min_value)

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



min_value = 2018

for i in range(L, R):

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

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

        if min_value == 0:

            break

    else:

        continue

    break

    

print(min_value)

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

L, R = list(map(int, input().split(" ")))
min_value = 2018
for i in range(L, R):
    for j in range(i + 1, R + 1):
        min_value = min(min_value, i * j % 2019)
        if min_value == 0:
            break
    else:
        continue
    break
print(min_value)

-if R - L >= 2018: -    print((0)) -else: -    min_value = 2018 -    for i in range(L, R): -        for j in range(i + 1, R + 1): -            min_value = min(min_value, i * j % 2019) -    print(min_value) +min_value = 2018 +for i in range(L, R): +    for j in range(i + 1, R + 1): +        min_value = min(min_value, i * j % 2019) +        if min_value == 0: +            break +    else: +        continue +    break +print(min_value)