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

a=L%2019

b=R%2019



T=[]

ans=float("inf")

if a<b:

	T=list(range(a,b+1))

	if R-L>2018:

		print(0)

		quit()

	else:

		l=len(T)

		for i in range(l):

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

				ans=min(ans, (T[i]*T[j])%2019 )



		print(ans)

else:

	print(0)

	quit()



import sys

L,R=list(map(int, sys.stdin.readline().split()))

sho1=(L-1)/2019

sho2=R/2019

if 1<=sho2-sho1:

    print(0)

else:

    ans=float("inf")

    for i in range(L,R):

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

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

    print(ans)
L, R = list(map(int, input().split()))
a = L % 2019
b = R % 2019
T = []
ans = float("inf")
if a < b:
    T = list(range(a, b + 1))
    if R - L > 2018:
        print(0)
        quit()
    else:
        l = len(T)
        for i in range(l):
            for j in range(i + 1, l):
                ans = min(ans, (T[i] * T[j]) % 2019)
        print(ans)
else:
    print(0)
    quit()

import sys

L, R = list(map(int, sys.stdin.readline().split()))
sho1 = (L - 1) / 2019
sho2 = R / 2019
if 1 <= sho2 - sho1:
    print(0)
else:
    ans = float("inf")
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans = min(ans, i * j % 2019)
    print(ans)

-L, R = list(map(int, input().split())) -a = L % 2019 -b = R % 2019 -T = [] -ans = float("inf") -if a < b: -    T = list(range(a, b + 1)) -    if R - L > 2018: -        print(0) -        quit() -    else: -        l = len(T) -        for i in range(l): -            for j in range(i + 1, l): -                ans = min(ans, (T[i] * T[j]) % 2019) -        print(ans) +import sys + +L, R = list(map(int, sys.stdin.readline().split())) +sho1 = (L - 1) / 2019 +sho2 = R / 2019 +if 1 <= sho2 - sho1: +    print(0) -    print(0) -    quit() +    ans = float("inf") +    for i in range(L, R): +        for j in range(i + 1, R + 1): +            ans = min(ans, i * j % 2019) +    print(ans)