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

if R-L>2019:   print((0))

else:

    ans=[i*j%2019 for i in range(L,R) for j in range(L+1,R+1)]

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

ans=0

if R-L<2019:

    ans=min([i*j%2019 for i in range(L,R) for j in range(i+1,R+1)])

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

L, R = list(map(int, input().split()))
ans = 0
if R - L < 2019:
    ans = min([i * j % 2019 for i in range(L, R) for j in range(i + 1, R + 1)])
print(ans)

-if R - L > 2019: -    print((0)) -else: -    ans = [i * j % 2019 for i in range(L, R) for j in range(L + 1, R + 1)] -    print((min(ans))) +ans = 0 +if R - L < 2019: +    ans = min([i * j % 2019 for i in range(L, R) for j in range(i + 1, R + 1)]) +print(ans)