def mod2019(x, y):

    return (x%2019 * y%2019 ) % 2019



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

ans=2019

s=set()

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

    if i%2019 in s:

        break

    s.add(i%2019)

l = list(s)

for i in range(len(l)):

    for j in range(i+1, len(l)):

#        print(i, j, l[i], l[j], mod2019(l[i], l[j]))

        ans=min(ans, mod2019(l[i], l[j]))

    

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

if R-L >= 2019:

    print((0))

    exit()

    

s=set()

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

    if i%2019 in s:

        break

    s.add(i%2019)

l = list(s)



if 3 in l and 673 in l:

    print((0))

    exit()

    

print((min([(i*j)%2019 for i in l for j in l if i != j])))
def mod2019(x, y):
    return (x % 2019 * y % 2019) % 2019


L, R = list(map(int, input().split()))
ans = 2019
s = set()
for i in range(L, R + 1):
    if i % 2019 in s:
        break
    s.add(i % 2019)
l = list(s)
for i in range(len(l)):
    for j in range(i + 1, len(l)):
        #        print(i, j, l[i], l[j], mod2019(l[i], l[j]))
        ans = min(ans, mod2019(l[i], l[j]))
print(ans)

L, R = list(map(int, input().split()))
if R - L >= 2019:
    print((0))
    exit()
s = set()
for i in range(L, R + 1):
    if i % 2019 in s:
        break
    s.add(i % 2019)
l = list(s)
if 3 in l and 673 in l:
    print((0))
    exit()
print((min([(i * j) % 2019 for i in l for j in l if i != j])))

-def mod2019(x, y): -    return (x % 2019 * y % 2019) % 2019 - - -ans = 2019 +if R - L >= 2019: +    print((0)) +    exit() -for i in range(len(l)): -    for j in range(i + 1, len(l)): -        #        print(i, j, l[i], l[j], mod2019(l[i], l[j])) -        ans = min(ans, mod2019(l[i], l[j])) -print(ans) +if 3 in l and 673 in l: +    print((0)) +    exit() +print((min([(i * j) % 2019 for i in l for j in l if i != j])))