import numpy as np

L,R = (int(x) for x in input().split())



if R - L > 3000:

  print((0))

  exit()

  

x = np.arange(L,R+1,dtype=np.int64)

y = x[:,None] * x[None,:] % 2019

for i in range(len(x)):

  y[i,i] = 3000

answer = y.min()

print(answer)
import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



import numpy as np



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



if R-L > 1000:

    print((0))

    exit()

x = np.arange(L,R+1)

x = x[:,None] * x[None,:] % 2019

np.fill_diagonal(x,2019)

answer = x.min()

print(answer)
import numpy as np

L, R = (int(x) for x in input().split())
if R - L > 3000:
    print((0))
    exit()
x = np.arange(L, R + 1, dtype=np.int64)
y = x[:, None] * x[None, :] % 2019
for i in range(len(x)):
    y[i, i] = 3000
answer = y.min()
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

L, R = list(map(int, read().split()))
if R - L > 1000:
    print((0))
    exit()
x = np.arange(L, R + 1)
x = x[:, None] * x[None, :] % 2019
np.fill_diagonal(x, 2019)
answer = x.min()
print(answer)

+import sys + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines -L, R = (int(x) for x in input().split()) -if R - L > 3000: +L, R = list(map(int, read().split())) +if R - L > 1000: -x = np.arange(L, R + 1, dtype=np.int64) -y = x[:, None] * x[None, :] % 2019 -for i in range(len(x)): -    y[i, i] = 3000 -answer = y.min() +x = np.arange(L, R + 1) +x = x[:, None] * x[None, :] % 2019 +np.fill_diagonal(x, 2019) +answer = x.min()