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



if R-L>=2018:

  print((0))

else:

  M=[]

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

    M.append(i%2019)

  #print(M)

  A=[]

  for i in M:

    for j in M:

      if i!=j:

        A.append(i*j%2019)

  #print(A)

  print((min(A)))

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



if R - L > 2020:

  print((0))

else:

  answer = []

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

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

      answer.append((i * j) % 2019)

  

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

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

-if R - L >= 2018: +if R - L > 2020: -    M = [] +    answer = [] -        M.append(i % 2019) -    # print(M) -    A = [] -    for i in M: -        for j in M: -            if i != j: -                A.append(i * j % 2019) -    # print(A) -    print((min(A))) +        for j in range(i + 1, R + 1): +            answer.append((i * j) % 2019) +    print((min(answer)))