You are given two non-negative integers L and R.
We will choose two integers i and j such that L \leq i < j \leq R.
Find the minimum possible value of (i \times j) \mbox{ mod } 2019.

-----Constraints-----
 - All values in input are integers.
 - 0 \leq L < R \leq 2 \times 10^9

-----Input-----
Input is given from Standard Input in the following format:
L R

-----Output-----
Print the minimum possible value of (i \times j) \mbox{ mod } 2019 when i and j are chosen under the given condition.

-----Sample Input-----
2020 2040

-----Sample Output-----
2

When (i, j) = (2020, 2021), (i \times j) \mbox{ mod } 2019  = 2.

Difficulty: introductory

Starter code:

Solutions:
l, r = list(map(int, input().split()))

if (r-l)//2019 >= 1:
    print((0))
else:
    ans = float('inf')
    for i in range(l, r+1):
        for j in range(l, r+1):
            if i != j:
                ans = min(ans, (i*j)%2019)

    print(ans)


L,R = map(int,input().split())
kouho = set([])
while len(kouho) < 2019 and L <= R:
  temp = L%2019
  kouho.add(temp)
  L += 1
#print(kouho)
A = list(kouho)
A.sort()
ans = 2018
for i in range(len(A)):
  for j in range(i+1,len(A)):
    temp = A[i]*A[j]%2019
    ans = min(ans,temp)
print(ans)

l,r=list(map(int,input().split()))
m=2019
if l//m<r//m:
  print((0))
else:
  ans=m
  for i in range(l%m, r%m+1):
    for j in range(i+1,r%m+1):
      ans=min(ans,i%m*j%m)
  print(ans)


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

if r - l >= 2019:
    print((0))
else:
    m = 2019
    for i in range(l, r + 1, 1):
        for j in range(i+1, r + 1, 1):
            m = min(i * j % 2019, m)
    print(m)


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

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

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


L,R = map(int,input().split())
if R-L+1 >= 2019:
    print(0)
    return
R %= 2019
L %= 2019
if R <= L:
    print(0)
    return
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 = map(int,input().split())
ans = 2019

for i in range(L,R+1):
    for j in range(i+1,R+1):
        if(j % 2019 == 0):
            print(0)
            return
        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)

import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    l, r = inl()
    if r - l > 2200:
        return 0
    a = 2018
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            x = (i * j) % 2019
            a = min(a, x)
    return a


print(solve())


import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

def main():
    l, r = list(map(int, input().split()))
    diff = r-l
    if diff >= 2018:
        return 0

    else:
        min_ = 2 ** 20
        # l の商と余り
        p = l // 2019 ; q = l % 2019
        for xi in range(l, r):
            qi = (q + (xi - l)) % 2019
            if qi == 0:
                return 0
            for xj in range(xi+1, r+1):
                qj = (q + (xj - l)) % 2019
                if qj == 0:
                    return 0
                else:
                    qij = (qi * qj) % 2019
                    if qij < min_:
                        min_ = qij

    return min_

print(main())

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)

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


l, r = map(int,input().split())
ans = float("INF")
mod = 2019

for i in range(l, r+1):
  if i == l+2019 or ans == 0: break
  for j in range(l, r+1):
    if j == l+2019: break
    if i == j: continue
    ans = min(ans, (i*j) % mod)
print(ans)

import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    L,R = i_map()
    ans = 2018
    for i in range(L,min(R+1,L+2030)):
        for j in range(L+1,min(R+1,L+2030)):
            if i != j:
                ans = min(ans, (i*j)%2019)

    print(ans)

  


def __starting_point():
    main()
__starting_point()

L,R=map(int,input().split())
k = 0
l = 2020
m = 2020
apList = [0]*2019
for i in range(L,R+1):
  k = i % 2019
  if apList[k] != 0:
    break
  else:
    apList[k] += 1
res = 2018
for i in range(2019):
  for j in range(i+1,2019):
    if apList[i] != 0 and apList[j] !=0:
      res = min(i*j %2019,res)
print(res)

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

if r - l >= 2019:
    print(0)
else:
    m = 2019
    for i in range(l, r + 1, 1):
        for j in range(i+1, r + 1, 1):
            m = min(i * j % 2019, m)
    print(m)

l,r=list(map(int,input().split()))
m=ans=2019
if l//m<r//m:
  print((0))
else:
  a,b=l%m,r%m
  for i in range(a, b+1):
    for j in range(i+1,b+1):
      ans=min(ans,(i*j)%m)
  print(ans)


import itertools

L,R = list(map(int,input().split()))
if R - L + 1 >= 2019:
    ans = 0
else:
    LL = L % 2019
    RR = R % 2019
    if LL < RR:
        Amari_List = list(range(LL,RR+1))
        ans = 2019
        for v1,v2 in itertools.combinations(Amari_List, 2):
            ca = (v1*v2) % 2019 
            if  ca < ans:
                ans = ca
    else:
        ans = 0

print(ans)





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

print(ans)


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

mod = 2019

ans = 2222

if (r - l) // mod > 0:
	ans = 0

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

print(ans)

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

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

print(ans)

l,r = list(map(int,input().split()))
MOD = 2019
ans = MOD

if r-l+1>=MOD:
    kouho=list(range(MOD))
else:
    kouho=[i%MOD for i in list(range(l,r+1))]
    
for i in range(len(kouho)):
    for j in range(i+1,len(kouho)):
        ans=min(ans,(kouho[i]*kouho[j])%MOD)

print(ans)


# AtCoder Beginner Contest 133
# C - Remainder Minimization 2019
L,R=map(int,input().split())

mod=2019
ans=10**18+7


for i in range (L,min(R,L+mod)):
    for j in range (L+1,min(R+1,L+mod+1)):
        tempans=(i%mod)*(j%mod)
        tempans%=mod
        # print(i,j,tempans)
        if tempans<ans:
            ans=tempans
print(ans)

L, R = list(map(int, input().split()))
if L + 2019 > R:
  tmp = 10**9
  for l in range(L,R):
    for r in range(l+1, R+1):
      if (l*r)%2019 < tmp:
        tmp = (l*r)%2019
  print(tmp)
else:
  print("0")



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


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

l,r = map(int,input().split())
ans = 2019
for i in range(l,r+1):
  for j in range(i+1,r+1):
    ans = min(ans,(i*j)%2019)
    if ans == 0:
      print(0)
      return
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())
ans = 2019
if r-l >= 2018:
  print(0)
else:
  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 -*-
"""
Created on Thu Sep 10 11:33:13 2020

@author: liang
"""

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

import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    S = set()
    L, R = MI()
    mod = 2019
    if R // mod > (L-1) // mod:
        print(0)
        return

    l = [i % mod for i in range(L, R+1)]
    l.sort()
    ans = float('inf')

    N = len(l)
    for index in range(N):
        for index2 in range(index+1, N):
            ans = min(ans, (l[index]*l[index2]) % mod)
            if ans < 1:
                break
        else:
            continue
        break
    
    print(ans)
def __starting_point():
    main()
__starting_point()

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

MOD = 2019

ans = 2020**2

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

import sys


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

k=2020
if r-l>=2020:
    print(0)
    return
else:
    for i in range(l,r):
        for j in range(i+1,r+1):
            k=min(k,(i*j)%2019)
print(k)

l, r = list(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(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)
    return
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)

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-10 18:36:43 +0900
# LastModified: 2020-09-11 02:01:32 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    L, R = list(map(int, input().split()))
    cool = R // 2019 - L // 2019
    if cool == 0:
        ans = 2020
        for l in range(L, R+1):
            for r in range(l+1, R+1):
                if ans > l*r % 2019:
                    ans = l*r % 2019
        print(ans)

    else:
        print((0))


def __starting_point():
    main()

__starting_point()

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

if r - l >=2019:
  x = 0
  
else:
  for i in range(l,r):
    for j in range(i+1, r+1):
      if (i * j) % 2019 < x:
        x = (i * j) % 2019
        
print(x)

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


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)


def __starting_point():
    main()
__starting_point()

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

if R - L >= 2018:
    print("0")
else:
    ans = 2020
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            t = ((i%m) * (j%m)) % m
            ans = min(ans, t)
    print(ans)


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

import sys
L,R = map(int,input().split())
mod = 2019
if R - L >= 2019:
    print(0)
else:
    ans = 10**8
    for i in range(L,R):
        for j in range(i+1,R+1):
            if i * j % mod == 0:
                print(0)
                return
            ans = min(ans,(i*j)%mod)
    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 = [int(i) for i in input().split()]

c = set()

for i in range(L, R + 1):
  t = i % 2019
  if t in c:
    break
  c.add(t)


m = float('inf')
l = list(c)
for i in range(len(l)):
  for j in range(i + 1, len(l)):
    m = min(m, l[i] * l[j] % 2019)

print(m)


def main():
    l, r = list(map(int, input().split()))
    mi = 2019
    c = 0

    for i in range(l, r):
        a = (i*i) % 2019
        for _ in range(min(r-l-c, 2019)):
            a = (a+i) % 2019

            if a < mi:
                mi = a
                if a == 0:
                    print((0))
                    return 
        c += 1

    print(mi)


def __starting_point():
    main()

__starting_point()

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)

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

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

def main():
    l, r = map(int, input().split())
    q, ll = l // 2019, l % 2019
    rr = r % 2019
    rng = [*range(ll, rr+1)] if r - l < (2019 * q - ll) % 2019 else [*range(ll, 2019)] + [*range(rr+1)]
    lenrng = len(rng)
    ans = 2020
    for i in range(lenrng-1):
        for j in range(i+1, lenrng):
            tmp = rng[i] * rng[j] % 2019
            if tmp < ans:
                ans = tmp
    print(ans)

def __starting_point():
    main()
__starting_point()

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

import itertools
l,r = map(int,input().split())
if r-l >= 2019:
    print(0)
    return
w = []
q = list(itertools.combinations(range(l,r+1),2))
for i in range(len(q)):
    w.append((q[i][0]*q[i][1])%2019)

print(min(w))

l ,r = list(map(int, input().split()))
t = []
if r-l >= 2019:
  print((0))
  return
elif r-l < 2019:
  if 2019 <= l:
    for i in range(l, r):
      for j in range(i+1, r+1):
        ii = i % 2019
        jj = j % 2019
        s = (ii*jj) % 2019
        t.append(s)
    ans = min(t)
    print(ans)
  elif l < 2019 < r:
    for i in range(l, r):
      for j in range(i+1, r+1):
        ii = i % 2019
        jj = j % 2019
        s = (ii*jj) % 2019
        t.append(s)
    ans = min(t)
    print(ans)
  elif r <= 2019:
    for i in range(l, r):
      for j in range(i+1, r+1):
        s = (i*j) % 2019
        t.append(s)
    ans = min(t)
    print(ans)


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

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


#!/usr/bin/env python3

def main():
    l, r = list(map(int, input().split()))
    ans = 2019
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            ans = min(ans, i * j % 2019)
            if ans == 0:
                break
        if ans == 0:
            break
    print(ans)


def __starting_point():
    main()

__starting_point()

L, R = map(int, input().split(' '))
rst = float('inf')
if R > L + 2019 * 2:
    R = R % 2019 + 2019
else:
    R %= 2019
L %= 2019
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        rst = min(rst, (i * j) % 2019)
print(rst)

l, r = map(int, input().split())
ans = 2019
if r - l <= 2021:
    for i in range(l, r):
        for j in range(i+1, r+1):
            a = ((i%2019)*(j%2019))%2019
            ans = min(a, ans)
    print(ans)
else:
    for p in range(l, l+2021):
        for q in range(p+1, l+2022):
            b = ((p%2019)*(q%2019))%2019
            ans = min(b, ans)
    print(ans)

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

if (r-l) > 2100:
  print(0)
  return

ans=9999

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

import sys

def read_str(): return sys.stdin.readline().strip()
def read_int(): return int(sys.stdin.readline().strip())
def read_ints(): return list(map(int, sys.stdin.readline().strip().split()))
def read_str_split(): return list(sys.stdin.readline().strip())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))

def Main():
    l, r = read_ints()
    ans = 2020
    if r - l >= 2019:
        print((0))
        return
    for i in range(l, r + 1):
        for j in range(l, i):
            ans = min(ans, i * j % 2019)
    print(ans)

def __starting_point():
    Main()

__starting_point()

L, R = map(int, input().split())
 
# 例：L=3000, R=10000 で考える
# (i,j)=(3000,3001)から始まり、(3000,5018)で最小(=0)
 
# R-L>=2018 のとき、(L,L+1),...,(L,L+2018)の間で最小値0を取れる
# それ以外のとき、全探索してもO((10^3)^2)で間に合う！
if R-L >= 2018:
  print(0)
else:
  m = 2019
  for i in range(L, R):
    for j in range(i+1, R+1):
      m = min(m, i*j % 2019)
  print(m)

L,R = map(int,input().split())
MOD = 2019
ans = 2020
if R - L > 2010:
  print(0)
  return
for i in range(L,R):
    for j in range(i+1,R+1):
        ans = min(ans,i*j%MOD)
print(ans)

L, R = list(map(int, input().split()))
ans = 2018
for i in range(L, R):
    for j in range(i + 1, R + 1):
        a = (i * j) % 2019
        if a < ans:
            ans = a
        if ans == 0:
            break
    else:
        continue
    break
print(ans)


MOD = 2019

l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
    return
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=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 = 2019
for i in range(L, L+2020-1):
    for j in range(i+1, i+2020):
        if j > R: break
        ans = min((i*j)%2019, ans)
print(ans)

L,R = map(int,input().split())
if R-L+1 >= 2019:
    print(0)
    return
R %= 2019
L %= 2019
if R <= L:
    print(0)
    return
ans = 2020
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())
l1=L//2019
r1=R//2019
if l1<r1:
  print(0)
elif l1==r1:
  res=[]
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      res.append((i*j)%2019)
  print(min(res))

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

if R - L >= p:
    print(0)
else:
    res = p
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            res = min(res, i * j % p)
    print(res)

#50 C - Remainder Minimization 2019 AC (hint)
L,R = map(int,input().split())

ans = 2020
# O(2019*2019)
# i は 2019 個以下
for i in range(L,R+1):
    # j は　2019 個以下
    for j in range(i+1,R+1):
        n = i*j
        if n%2019 == 0:
            ans = 0
            break
        n = n%2019
        ans = min(ans,n)
    else:
        continue
    break
print(ans)

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


#import math
#import itertools
#import numpy as np
#from collections import deque
# sys.setrecursionlimit(10 ** 6)
#mod = 10 ** 9 + 7
#INF = 10 ** 9
#PI = 3.14159265358979323846

INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    l,r=INTM()
    mods=[]
    for i in range(l,min(l+3000,r+1)):
        mods.append(i%2019)
    
    ans=2018
    ml=len(mods)
    for i in range(ml-1):
        for j in range(i+1,ml):
            ans=min(ans,(mods[i]*mods[j])%2019)

    print(ans)


def __starting_point():
    do()
__starting_point()

# ABC 133 C
[L, R] = [int(i) for i in input().split()]
ans = 2018
if R - L >= 2018:
    ans = 0
    #print('a')
else:
    l = L%2019
    r = R%2019
    if r < l:
        ans = 0
     #   print('b')
    else:
        for i in range(l, r):
            for j in range(i+1, r+1):
                if (i*j)%2019 < ans:
                    ans = (i*j)%2019
      #              print('c')
print(ans)

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

def mod(num):
    return num % 2019


#  (2019a + x)(2019b + y) = 2019(n) + xy

ans = 10 ** 9

lr = min(R, L + 2019) + 1

for i in range(L, lr):
    for j in range(i + 1, lr):
        ans = min(ans, mod(i * j))
        
print(ans)

import itertools

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

for i in range((2*10**9)//2019+1):
	if L<=i*2019 and i*2019<=R:
		print(0)
		return

ans=2020

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

print(ans)

L, R = map(int,input().split())
Dif = abs(L-R)+1
if Dif >= 2020:
    Ans = 0
else:
    Box = []
    for i in range(L,R+1):
        Box.append(i%2019)
    Box.sort()
    Ans = 2020*2020
    for i in range(len(Box)-1):
        B1 = Box[i]
        for j in range(i+1,len(Box)):
            B2 = Box[j]
            Ans = min((B1*B2)%2019, Ans)
print(Ans%2019)

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

if R-L < 2018:
  nums = list(range(L,R+1))
  A = []
  for i in range(len(nums)):
    for j in range(i+1,len(nums)):
      A.append((nums[i]*nums[j])%2019)
  ans = min(A)

print(ans)

L, R = map(int, input().split())
result = R*R
if R - L + 1 > 2019:
    R = L + 2018
for i in range(L,R+1):
    for j in range(i+1,R+1):
        if (i * j) % 2019 < result:
            result = (i * j) % 2019
print(result)


MOD = 2019
L, R = list(map(int, input().split()))
mod_l = L % MOD
mod_r = R % MOD

if R - L >= 2019:
    print("0")
else:
    ans = 2018
    for i in range(mod_l, mod_r):
        for j in range(i+1, mod_r+1):
            _ans = (i * j) % MOD
            if ans > _ans:
                ans = _ans
    print(ans)


L, R = map(int, input().split(' '))
rst = float('inf')
if R >= L + 2019:
    R = R % 2019 + 2019
else:
    R %= 2019
L %= 2019
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        rst = min(rst, (i * j) % 2019)
print(rst)

L, R = list(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 sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    S = set()
    L, R = MI()
    mod = 2019
    if R // mod > (L-1) // mod:
        print(0)
        return
    l = [i % mod for i in range(L, R+1)]
    ans = float('inf')
    N = len(l)
    for index in range(N):
        for index2 in range(index+1, N):
            ans = min(ans, (l[index]*l[index2]) % mod)
    
    print(ans)
def __starting_point():
    main()
__starting_point()

l,r = map(int,input().split())
mod = 2019
a = l%mod
b = r%mod

if r-l >= 2018:
    print(0)

else:
    if a > b:
        print(0)
    else:
        t = (a*(a+1))%mod
        for x in range(a,b):
            for y in range(x+1,b+1):
                if (x*y)%mod < t:
                    t = (x*y)%mod
        print(t)

L, R = list(map(int, input().split()))
if R-L >=2019:
    minimum = 0
else:
    left, right = L%2019, R%2019
    minimum = 2019**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(' '))
rst = float('inf')
if R > L + 2019:
    R = R % 2019 + 2019
else:
    R %= 2019
L %= 2019
for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
        rst = min(rst, (i * j) % 2019)
print(rst)

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

a=min(r+1,l+2019)

b=2019
for i in range(l,a):
    for j in range(l,a):
        if i==j:
            continue
        else:
            b=min(b,(i*j)%2019)

print(b)

l,r = map(int, input().split())
m = 2019
for i in range(l,min(r+1,l+2020)):
    for j in range(i+1, min(r+1,l+2020)):
        i %= 2019
        j %= 2019
        m = min(m, (i*j)%2019)
print(m%2019)

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

if R-L > 2019:
  print(0)
  return
  
res = 100000
for i in range(L,R):
  ii = i%2019
  for j in range(i+1,R+1):
    j %= 2019
    res = min(res,ii*j%2019)
  
print(res)

# AtCoder Beginner Contest 133
# C - Remainder Minimization 2019
L,R=map(int,input().split())

mod=2019
ans=20000

for i in range (L,min(R,L+mod)):
    for j in range (L+1,min(R+1,L+mod+1)):
        tempans=(i%mod)*(j%mod)
        tempans%=mod
        if tempans<ans:
            ans=tempans

print(ans)

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

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

l, r = map(int, input().split())
l_mod = l % 2019
r_mod = r % 2019
if l + 2019 <= r:
    print(0)
    return
m = 3000
for i in range(l_mod, r_mod+1):
    for j in range(i+1, r_mod+1):
        m = min(m, i * j % 2019)
print(m)

L,R = (int(x) for x in input().split())
if R-L > 2019*2:
  R -= ((R-L)//2019-1)*2019
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())

ans = 2018**2
for i in range(l, min(r, l+2019)):
    v = i % 2019
    for j in range(l+1, min(r+1, l+2020)):
        w = j % 2019
        ans = min(ans, (v*w)%2019)
print(ans)

def main():
    l, r = map(int, input().split())
    ans = 2019
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            ans = min(ans, i * j % 2019)
            if ans == 0:
                break
        if ans == 0:
            break
    print(ans)
 
 
def __starting_point():
    main()
__starting_point()

import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

def main():
    l, r = list(map(int, input().split()))
    diff = r-l
    if diff >= 2018:
        return 0

    else:
        min_ = 2 ** 20
        # l の商と余り
        p = l // 2019 ; q = l % 2019
        for xi in range(l, r):
            qi = (q + (xi - l)) % 2019
            if qi == 0:
                return 0
            for xj in range(xi+1, r+1):
                qj = (q + (xj - l)) % 2019
                if qj == 0:
                    return 0
                else:
                    qij = (qi * qj) % 2019
                    if qij < min_:
                        min_ = qij

    return min_

print(main())

L, R = map(int, input().split())
 
m = 2019
flag = False
for i in range(L, R):
  for j in range(i+1, R+1):
    m = min(m, i*j % 2019)
    if m == 0: 
      flag = True
      break
  if flag: break
      
print(m)

L, R = map(int, input().split())
MOD = 2019
if MOD <= R - L + 1:
  ans = 0
else:
  ans = MOD - 1
  nums = set()
  start = L%MOD
  for i in range(start, start + (R - L) + 1):
    if i%MOD in nums:
      break
    nums.add(i%MOD)
  nums = tuple(nums)
  for i in range(len(nums)):
    for j in range(i+1, len(nums)):
      ans = min(ans, nums[i]*nums[j]%MOD)
print(ans)

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

# 例：L=3000, R=10000 で考える
# (i,j)=(3000,3001)から始まり、(3000,5018)で最小(=0)

# R-L>=2019 のとき、(L,L+1),...,(L,L+2019)の間で最小値0を取れるので、高々2018回の探索
# 全探索しても break すれば間に合う！
m = 2019
flag = False
for i in range(L, R):
  for j in range(i+1, R+1):
    m = min(m, i*j % 2019)
    if m == 0: 
      flag = True
      break
  if flag: break

print(m)

#ABC133 C

L,R = map(int,input().split())
A = []
if R - L > 2019:
    print(0)
elif 2 <= R - L and R - L <= 2019:
    for i in range(L,R):
        for j in range(i+1,R+1):
            A.append((i*j)%2019)
    print(min(A))
elif R - L == 1:
    print((R*L)%2019)