peterverebics/CodeNet_Python_118 huggingface dataset:
l,r = map(int,input().split())

if r-l >= 2018:
  print(0)
else:
  ans = 2019
  for i in range(l,r):
    for j in range(i+1,r+1):
      ans = min(ans,(i*j)%2019)
  print(ans)
L, R = map(int, open(0).read().split())

ans = 2020
m = min(L + 2020, R) + 1
for i in range(L, m):
    for j in range(i + 1, m):
    	ans = min(ans, i * j % 2019)

print(ans)
def main():
    L, R = map(int, input().split())
    R = min(R, L + 4038)
    ans = 2018

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

    print(ans)

if __name__ == "__main__":
    main()
l,r = map(int,input().split())
m = 2018
if r - l >= 2019:
    print(0)
    exit()
else:
    for i in range(l,r):
        for j in  range(i+1,r+1):
            m = min(m,i*j % 2019)
print(m)
l, r = [int(x) for x in input().split()]

ans = 2200
for i in range(l, r):
    if i % 2019 == 0:
        ans = 0
        break
    else:
        for j in range(i+1, r+1):
            if i == j:
                continue
            elif j % 2019 == 0:
                ans = 0
                break
            else:
                tmpans = (i * j) % 2019
            ans = min(ans, tmpans)


print(ans)
l, r = map(int, input().split())

ans_list = []
for i in range(l, min(l+2019, r)):
  for j in range(i + 1, min(i + 2019, r + 1)):
    ans = (i * j) % 2019
    ans_list.append(ans)
    if ans == 0:
      break
print(min(ans_list))
L,R=map(int,input().split())

result=float("inf")
R=min(R,L+4038)
for i in range(L,R+1):
  for j in range(i+1,R+1):
    result=min(result,i*j%2019)
#if R-L>= 2019:
#  result=0
#else:
#  l=L%2019
#  r=R%2019
#  for i in range(l,r+1):
#    for j in range(i+1,r+1):
#      result=min(result,i*j%2019)

print(result)
l,r=map(int,input().split())
if r-l>=2019: print(0)
else:
    ans=2018
    mod_l=l%2019
    mod_r=r%2019
    for i in range(min(mod_l,mod_r),max(mod_l,mod_r)+1):
        for j in range(i+1,max(mod_l,mod_r)+1):
            mod=(i*j)%2019
            if mod<ans: ans=mod
    print(ans)
MOD = 2019

l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
    exit()
lst = []
for num in range(l, r + 1):
    lst.append(num % MOD)
ans = 2020
ll = len(lst)
for i in range(ll):
    for j in range(i + 1, ll):
        tmp = (lst[i] * lst[j]) % MOD
        ans = min(ans, tmp)
print(ans)
L,R=list(map(int, input().split()))
M=2019
if R-L==1:
  print(((R%M)*(L%M))%M)
  exit()
if L//M!=R//M:
  print(0)
  exit()
L=L%M
R=R%M
ans=M
for i in range(L,R+1):
  for j in range(i+1,R+1):
    ans=min(ans,(i*j)%M)
print(ans)
from itertools import combinations

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

# check
mod0 = [n for n in range(0, R + 1, 2019) if L <= n]
if not mod0:
    target_num = list(range(L, R + 1))
    nC2 = list(combinations(target_num, 2))
    mods_ans = [(i * j) % 2019 for i, j in nC2]

    print(min(mods_ans))
else:
    print(0)
l, r = map(int, input().split())
if r - l - 1 >= 2019:
    print(0)
else:
    ans = 2019
    for i in range(r - l):
        for j in range(i + 1, r - l + 1):
            if ans > ((i + l) * (j + l)) % 2019:
                ans = ((i + l) * (j + l)) % 2019
    print(ans)
import sys

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

ans = 2019
for i in range(L,R):
    for j in range(i+1,R+1) :
        pro = (i*j) %2019
        ans = min(ans,pro)
        if ans == 0 :
            print(0)
            sys.exit()

print(ans)
L,R=map(int,input().split())
l=L%2019
r=R%2019
#print(l,r)
if l<r and L//2019 == R//2019:
    ans=10**18
    for i in range(l,r):
        for j in range(l+1,r+1):
            if ans>(i*j)%2019:
                ans=(i*j)%2019
    print(ans)
elif L//2019<R//2019:
    print(0)
L,R = map(int,input().split())
ans = float('inf')
for i in range(L,R):
  for j in range(i+1,R+1):
    if (i*j)%2019==0:
      print(0)
      exit()
    ans = min(ans,(i*j)%2019)
print(ans)
import math
INF = 2_000_000_001
L, R = list(map(int, input().split()))
if math.ceil(L / 2019) <= R // 2019:
    print(0)
else:
    res = INF
    for i in range(L % 2019, R % 2019):
        for j in range(L % 2019 + 1, R % 2019 + 1):
            res = min(res, (i * j) % 2019)
    print(res)
l,r=map(int,input().split())
if r-l>=2019:
    ans=0
else:
    ans=2018
    l=l%2019
    r=r%2019
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            ans=min(ans,i*j%2019)
print(ans)
l, r = list(map(int,input().split()))

if r - l >= 2019:
  print(0)
  
else:
  ll = l % 2019
  rr = r % 2019
  if rr < ll:
    print(0)
    
  else:
    keep = 2020
    for i in range(ll, rr+1):
      for j in range(i+1, rr+1):
        keep = min((i*j)%2019, keep)
    print(keep)
L, R = map(int, input().split())
res = [0] * 2019
for i in range(L, R + 1):
    if res[i % 2019] > 0:
        break
    else:
        res[i % 2019] += 1

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

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

if r-l >= 2019: print(0)
else:
  ans = float("inf")
  for i in range(l, r):
    for j in range(i+1, r+1):
      t = i*j%2019
      if t < ans: ans = t
  print(ans)
l, r=map(int,input().split())
if r-l>=2019:
    minimum=0
else:
    left,right=l%2019,r%2019
    minimum=2018**2
    for i in range(left,right+1):
        for j in range(i+1,right+1):
            minimum=min(minimum,i*j%2019)
print(minimum)
L, R = map(int, input().split())

ans = 10**9
for i in range(L, min(R, L+2019)+1):
    for j in range(i+1, min(R, L+2019)+1):
        ans = min(ans, (i % 2019) * (j % 2019) % 2019)

print(ans)
l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
    exit()

l = l%2019
r = r%2019

if l >= r:
    print(0)
else:
    ans = float('inf')
    for left in range(l, r):
        for right in range(left+1, r+1):
            ans = min(ans, (left*right)%2019)
    print(ans)
l,r=map(int,input().split())
mod=2019
ans=2018
if r-l+1>=2019 or r%mod<l%mod:
    ans=0
else:
    for i in range(l%mod,r%mod):
        for j in range(i+1,r%mod+1):
            temp=(i*j)%mod
            ans=min(ans,temp)

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

A = []
Lm = L % 2019
Rm = R % 2019
for _ in range(min(R - L + 1, 2019 * 2)):
    A.append(Lm)
    Lm = (Lm + 1) % 2019

A.sort()
ans = 2018
for i in range(len(A)):
    for j in range(i + 1, len(A)):
        ans = min(ans, (A[i] * A[j]) % 2019)
        if ans == 0:
            break

print(ans)
l,r = map(int,input().split())
ans = 2019
r = min(r+1,l+2020)

for i in range(l,r):
    for j in range(i+1,r):
        ans = min(ans,i*j%2019)

print(ans)
import itertools
L,R = map(int,input().split())
if 2019 <= (R - L) + 1:
  print(0)
  exit()
  
lst = list(range(L,R+1))
md = [x * y % 2019 for x,y in itertools.combinations(lst,2)]
md.sort()
print(md[0])
L, R = map(int, input().split())
MOD = 2019
INF = 10**5
ans = INF


if 2019 <= R-L:
    print(0)
else:
    x = L % MOD
    y = R % MOD
    if x < y:
        for i in range(x, y):
            for j in range(i+1, y+1):
                ans = min(ans, (i*j) % MOD)
            if ans == 0:
                break
        print(ans)
    else:
        print(0)
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

L, R = map(int, readline().split())

t1 = L - (L // 2019) * 2019
t2 = R - (L // 2019) * 2019
temp = 0
min_temp = 2019

if R - L >= 2019:
    print("0")
else:
    for i in range(t1, t2):
        for j in range(i + 1, t2 + 1):
            temp = (i * j) % 2019
            if temp < min_temp:
                min_temp = temp

    print(min_temp)
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

l,r = nm()

MOD = 2019

ans = 10**9
for i in range(l,min(r,l+2019)+1):
  for j in range(i+1,min(r,i+MOD)+1):
    ans=min(ans,((i%MOD)*(j%MOD))%MOD)

print(ans)
import sys

L, R = map(int, input().split())
P = 2019
if R - L >= 2019:
    print(0)
    sys.exit()
elif (R % P) - (L % P) < 0:
    print(0)
    sys.exit()

R %= P
L %= P
ans = 2019
for i in range(L, R):
    for j in range(i + 1, R + 1):
        ans = min(ans, (i * j) % P)
print(ans)
mod = 2019
l, r = map(int, input().split())
m = min(r, l + mod)
MN=[]
for i in range(l, m):
    for j in range(i+1, m+1):
        cand = i * j % mod
        if cand:
            MN.append(cand)
        else:
            print(0)
            exit()
print(min(MN))
l,r=map(int,input().split())
if r-l<2019:
    l=l
    r=r
else:
    l=l
    r=l+2019
ans=2019
for i in range(l,r):
    for j in range(i+1,r+1):
        if (i*j)%2019<ans:
            ans=(i*j)%2019
print(ans)
L, R = map(int, input().split())
min_rad = 2019
R_max = min(L+2019, R)
for i in range(L, R_max):
    for j in range(i+1, R_max+1):
        temp = i%2019 * j%2019
        if temp < min_rad:
            min_rad = temp
print(min_rad)
l,r = map(int,input().split())

cand = []
for i in range(l,r+1):
  cand.append(i%2019)
  if len(cand) == 2020*2:
    break
    
ans = float('inf')
for i in range(len(cand)):
  for j in range(len(cand)):
    if i==j:
      continue
    ans = min(ans, (cand[i]*cand[j])%2019)
    if ans ==0:
      break
  else:
    continue
  break
print(ans)
L, R = map(int, input().split())
if R - L >= 2019:
    mn = 0
else:
    l, r = L % 2019, R % 2019
    mn = 2018 ** 2
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            mn = min(mn, i * j % 2019)
print(mn)
l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
else:
    l %= 2019
    r %= 2019
    if r < l:
        print(0)
    else:
        ans = 2019
        for i in range(l, r):
            for j in range(i + 1, r + 1):
                ans = min(ans, i * j % 2019)
        print(ans)
l,r = map(int,input().split())
if r-l >=2019:
    print(0)
else:
    ans = 2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans = min(ans,i*j%2019)
    print(ans)
def resolve():
    '''
    code here
    '''
    L, R = [int(item) for item in input().split()]
    aL, bL = divmod(L, 2019)
    aR, bR = divmod(R, 2019)

    if bL == 0:
        res = 0
    elif aL < aR:
        res = 0
    elif aL == aR:
        res = 2019
        for i in range(bL,bR):
            for j in range(bL+1,bR+1):
                res = min(res, i*j%2019)

    print(res)
if __name__ == "__main__":
    resolve()
l,r=map(int,input().split())
M=2019;s=range(l,r+1)
print(0 if r//M-l//M>0 else min(i*j%M for i in s for j in s if i<j))
l, r = map(int, input().split())
m = 2019
if r - l >= 673:
    print(0)
else:
    ans = 2018
    for i in range(l, r):
        for j in range(i+1, r+1):
            ans = min(ans, (i*j)%m)
        if ans <= 2:
            break
    print(ans)
l, r = map(int, input().split())
#print(l,r)

best = 2019
for i in range(l, min(r,l+2019)):
	for j in range(l+1,min(r+1,l+2019+1)):
		if i*j % 2019 < best:
			best = i*j % 2019

print(best)
L,R=map(int,input().split())
if R-L>=2019:
    minimum=0
else:
    left,right=L%2019,R%2019
    minimum=2018**2
    for i in range(left,right+1):
        for j in range(i+1,right+1):
            minimum=min(minimum,i*j%2019)
print(minimum)
import numpy as np

def ABC133C(l, r):
    Min = np.inf
    for i in range(l, r):
        for j in range(i+1, r+1):
            a = (i * j) % 2019
            if a < Min:
                Min = a
                if a == 0: # ここに注目
                    print(Min)
                    return
    print(Min)

l, r = map(int, input().split())
ABC133C(l, r)
L, R = map(int, input().split())

MOD = 2019

if R - L >= MOD or L%MOD == 0 or R%MOD == 0:
    print(0)
else:
    LR = list(range(L, R+1))
    minimum = 2*10**9
    for i in range(len(LR)):
        l = LR[i]
        for r in LR[i+1:]:
            minimum = min(l*r%MOD, minimum)
    print(minimum)
L, R = map(int, input().split())

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

for i in range(L,R+1,1):
    if i%2019 == 0:
        print(0)
        exit()

ans = 2018
for i in range(L,R+1,1):
    for j in range(i+1,R+1,1):
        x = (i*j)%2019
        if x<ans:
            ans = x

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

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

print(ans)
L, R = map(int, input().split())
MOD = 2019
INF = 10**5
ans = INF


if 2019 <= R-L:
    print(0)
else:
    x = L % MOD
    y = R % MOD
    if x < y:
        for i in range(x, y):
            for j in range(i+1, y+1):
                ans = min(ans, (i*j) % MOD)
        else:
            print(ans)
    else:
        print(0)
#!/usr/bin/env python3
import itertools


def main():
    L, R = map(int, input().split())
    if R - L > 2017:
        print(0)
        return
    xs = [n % 2019 for n in range(L, R + 1)]
    ans = 2018
    for i, j in itertools.combinations(xs, 2):
        tmp = (i * j) % 2019
        if tmp == 0:
            ans = 0
            break
        else:
            if tmp < ans:
                ans = tmp

    print(ans)


if __name__ == '__main__':
    main()
L, R = map(int, input().split())
R = min(R, L+4038)
ans = 2018
for i in range(L, R):
    for j in range(i+1, R+1):
        ans = min((i*j)%2019, ans)
print(ans)
L, R = map(int, input().split())
mod = 2019
ans = mod - 1
R = min(R, L+mod-1)
for i in range(L, R):
  for j in range(i+1, R+1):
    ans = min(ans, i * j % mod)
print(ans)
l,r=map(int,input().split())
a=2018
for i in range (l,min(r,l+2019)):
  for j in range(i+1,min(r+1,i+2019)):
    c= ((i%2019)*(j%2019))%2019
    if c<a:
      a=c
print(a)
l, r = map(int, input().split())
if r - l > 2019:
    print(0)
else:
    ans = 2019
    for i in range(l, r):
        for j in range(i + 1, r + 1):
             ans = min(ans, (i * j) % 2019)
    print(ans)
# coding: utf-8
L, R = map(int, input().split())
mod = 2019
ans = float("inf")
for i in range(L, R + 1):
    i_mod = i % mod
    if i_mod == 0:
        ans = 0
        break
    for j in range(i + 1, R + 1):
        j_mod = j % mod
        if j_mod == 0:
            ans = 0
            break
        else:
            ans = min(ans, i * j % mod)
print(ans)
L, R = map(int, input().split())
a=[]

if R-L>=2019:
  ans=0
else:
  l, r = L%2019, R%2019
  ans=2018**2
  for i in range(l,r):
    for j in range(l+1,r+1):
        k = (i*j) % 2019
        ans = min(ans,k)
print(ans)
L, R = map(int, input().split())

ans = 10 ** 100
for i in range(L, R+1):
    if ans == 0: break
    for j in range(i+1, R+1):
        ans = min(ans, i * j % 2019)
        if ans == 0: break

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

if L == 0 or R-L >= 2019:
    ans = 0
else:
    ans = 10**18
    for i in range(L, R):
        for j in range(i+1, R+1):
            tmp = (i*j)%2019
            ans = min(ans, tmp)
            if not ans:
                break
print(ans)
import itertools
import math
import fractions
import functools
import copy

l, r = map(int, input().split())

if r - l > 2019:
    print(0)
    quit()

minimum = 10**10
for i in range(l, r+1):
    for j in range(l, r+1):
        if(i != j):
            minimum = min(minimum, (i*j) % 2019)

print(minimum)
import sys
l,r = map(int,input().split())
ans = int(2018)
if(r-l > 2020):
    print(0)
    sys.exit()
else:
    for i in range(l,r):
        for j in range(l+1,r+1):
            if((i*j)%2019 < ans):
                ans = (i*j)%2019
print(ans)
L,R=map(int,input().split())
ans=2019
for i in range(L,R):
	for j in range(i+1, R+1):
		if j%2019==0:
			print(0)
			exit()
		ans=min(ans,(i*j)%2019)
print(ans)
L,R=map(int,input().split())
if R-L+1>=671:
    print(0)
else:
    m=2019
    for i in range(L,R):
        for j in range(i+1,R+1):
            x=(i*j)%2019
            if x<m:
                m=x
    print(m)
L,R = map(int,input().split())
if R - L >= 2019:
    ans = 0
else:
    ans = 2018**2
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            ans = min(ans,(i*j)%2019)
print(ans)
def solve(L, R):
  minmod = float('inf')
  for i in range(L, R):
    for j in range(i + 1, R + 1):
      minmod = min((i * j) % 2019, minmod)
      if minmod == 0:
        return minmod
  return minmod

L, R = map(int, input().split(' '))
print(solve(L, R))
l, r = map(int,input().split())
 
ans = 2019
for i in range(l, r):
    for j in range(i+1, r+1):
        tmp = i*j % 2019
        if ans > tmp:
            ans = tmp
        if ans == 0:
            print(ans)
            exit(0)
print(ans)
L, R = map(int, input().split())

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

ans = 2019

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

print(ans)
L,R=map(int,input().split())
if (R-L>3000) :
    print(0)
else :
    ans=2019
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            ans=min(ans,i*j%2019)
    print(ans)
l,r=map(int,input().split())
m=l//2019
l-=m*2019
r-=m*2019
if r>=2019:
    print(0)
    exit()
ans=2018
for i in range(l,r+1):
    for j in range(i+1,r+1):
        ans=min(ans,i*j%2019)
print(ans)
l,r=map(int,input().split())
ans=10**15
for i in range(l,min(r,l+2100)):
  for j in range(i+1,min(r+1,l+2100)):
    ans=min(ans,(i*j)%2019)

print(ans)
import sys

a, b = map(int,input().split())
num = int(a*b%2019)

for i in range(a, b + 1):
  for j in range(i + 1, b + 1):
    if(i >= j):
      continue
    num = min(num, (i*j)%2019)
    if(num == 0):
      print(0)
      sys.exit()

print(num % 2019)
l,r = map(int,input().split())
cnt = 0
mod_list = []
if r- l >=2019:
    print(0)
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            mod_list.append(i*j%2019)
    print(min(mod_list))
import sys
mina=10**10
L,R=map(int,input().split())
for i in range(L,R):
  for j in range(i+1,R+1):
    i=i%2019
    j=j%2019
    mina=min(mina,(i*j)%2019)
    if mina==0:
      print(0)
      sys.exit()
print(mina)
L,R=map(int,input().split())
left,right=L%2019,R%2019
print(0 if R-L>=2019 else min([i*j%2019 for i in range(left,right+1) for j in range(i+1,right+1)]))
def main():

    L, R = [int(i) for i in input().split()]

    if (L//2019) < (R//2019):
        ans = 0
    else:
        ans = 10 ** 10
        for l in range(L, R+1):
            for r in range(l+1, R+1):
                ans = min(ans, (l*r)%2019)

    print(ans)


if __name__ == "__main__":
    main()
def solve():
    N, M = map(int, input().split())
    m = 10 ** 9
    for i in range(N, min(N+2019, M)):
        for j in range(N+1, min(N+2019, M)+1):
            m = min(m, i * j % 2019)
    return m

print(solve())
import sys
l, r = map(int, input().split())
lmod673 = l % 673
dif = r - l

if lmod673 + dif >= 673:
  print(0)
  sys.exit()

min_val = 2018
for bigger in range(l, r+1):
  for smaller in range(l, bigger):
    min_val = min(min_val, bigger*smaller % 2019)
print(min_val)
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

l,r = inpl()
r = min(r,l+3000)
res = INF
for i in range(l,r):
    for j in range(i+1,r+1):
        res = min(res, (i*j)%2019)
print(res)
mod=2019
L,R = map(int,input().split())

ls =[]

if R-L>=mod-1:
    print(0)
    exit()
else:
    for i in range(R-L+1):
        ls.append((L+i)%mod)

ans=10000
for i in range(len(ls)-1):
    for j in range(i+1,len(ls)):
        ans = min(ans,(ls[i]*ls[j])%mod)

print(ans)
import sys

l, r = map(int, input().split())

if 2019 <= r - l:
    print(0)
    sys.exit()

ans = 2019
for i in range(l, r):
    for j in range(i + 1, r + 1):
        i %= 2019
        j %= 2019
        ans = min(ans, (i * j) % 2019)

print(ans)
l,r = map(int,input().split())
sub = r-l
l %= 2019
r %= 2019

if(sub >= 2019):
    print(0)
    exit()

mina = float('INF')

for x in range(l,r+1):
    for y in range(x,r+1):
        if(x==y):
            continue
        
        ans = (x * y) % 2019
        if(mina > ans):
            mina = ans
       
print(mina)
from itertools import combinations

l, r = map(int, input().split())

ans = 2020
if r - l >= 2019:
    ans = 0
else:
    for i, j in list(combinations(range(l, r+1), 2)):
        ans = min(ans, (i*j)%2019)

print(ans)
l, r = map(int, input().split())
ans = 2019
for i in range(l, r):
    for j in range(i+1, r+1):
        tmp = i*j % 2019
        if ans > tmp:
            ans = tmp
        if ans == 0:
            print(ans)
            exit(0)
print(ans)
l, r = map(int, input().split())
m = 2019
if r - l >= 673:
    print(0)
else:
    ans = 2018
    l = l%m
    r = r%m
    for i in range(l, r):
        for j in range(i+1, r+1):
            ans = min(ans, (i*j)%m)
    print(ans)
l,r=map(int,input().split())

sho_l = l // 2019
sho_r = r // 2019

if sho_r-sho_l >= 1:
  print(0)
else:
  ans = 2018
  for i in range(l,r):
    for j in range(i+1,r+1):
      ans = min((i*j)%2019,ans)
  print(ans)
l,r = map(int,input().split())

ans = 2018
if r-l >= 2019:
    ans = 0
else:
    for i in range(l,r):
        for j in range(l+1,r+1):
            ans = min(i * j % 2019,ans)
print(ans)
L,R=map(int,input().split())
M=2019;l=L%M;r=R%M
print(0 if l>r or R-L>671 else min(i*j%M for i in range(l,r) for j in range(i+1,r+1)))
l, r = map(int, input().split())
interval = min(r - (l - 1), 2019)
min_remain = 2018
for i in range(l, l + interval):
    for j in range(i + 1, l + interval):
        if (i * j) % 2019 < min_remain:
            min_remain = (i * j) % 2019
print(min_remain)
L, R = list(map(int,input().split(" ")))
l = L % 2019
r = R % 2019

ans = 2019

if R - L >= 2018 or L > R:
    print("0")
else:
    array = list(range(l,r+1))
    for i in array:
        for j in array:
            if i == j:
                continue
            temp = i * j % 2019
            if ans > temp:
                ans = temp
    print(ans)
M=2019;l,r=map(int,input().split())
print(0 if r//M-l//M>0 else min(i*j%M for i in range(l,r) for j in range(i+1,r+1)))
m, n = map(int, input().split(" "))
if n - m >= 673:
    print(0)
else:
    score = m * n % 2019
    for i in range(m, n + 1):
        for j in range(i + 1, n + 1):
            if (i * j) % 2019 < score:
                score = (i * j) % 2019
    print(score)
L,R = map(int,input().split())
if R-L > 2019:
    print(0)
else:
    ans = 10**10
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(ans, i*j%2019)
    print(ans)
def LI():
    return list(map(int, input().split()))


L, R = LI()
ans = 2020
for i in range(L, R+1):
    for j in range(i+1, R+1):
        y = (i*j) % 2019
        ans = min(ans, y)
        if ans == 0:
            break
    if ans == 0:
        break
print(ans)
l,r = map(int, input().split())

q1 = l//2019
q2 = r//2019

if q1!=q2:
  print(0)
  exit()

r1 = l%2019
r2 = r%2019
ans = 2019
for i in range(r1,r2+1):
  for j in range(i+1,r2+1):
    rr = (i*j)%2019
    ans = min(ans,rr)
    if ans==0:
      print(ans)
      exit()
      
print(ans)
L,R = map(int,input().split())

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

print(ans)
l, r = map(int, input().split())
if l//2019<r//2019:
    print(0)
else:
    ans = 2019
    for ll in range(l, r):
        for rr in range(ll+1, r+1):
            ans = min(ans, (ll*rr)%2019)
    print(ans)
l, r = map(int, input().split())
a = []
if r - l > 2019:
  for i in range(l, l + 2019):
    for j in range(i + 1, min(r + 1, l + 2020)):
      a.append((i * j) % 2019)
else:
  for i in range(l, r):
    for j in range(i + 1, r + 1):
      a.append((i * j) % 2019)
ans = min(a)
print(ans)