import Data.Maybe
import Control.Monad
import qualified Data.ByteString.Char8 as C

readInteger' = fst.fromJust.C.readInteger
readLnInteger = map readInteger'.C.words<$>C.getLine
readCsInteger n = concat<$>replicateM n readLnInteger

x ? (a,b) = if x then a else b
half = flip div 2
aliq = ((0==).).mod

main = do
 [l,r] <- readLnInteger
 print $ solve [l,r]

solve [l,r]
 | any (\x -> aliq x 2019) [l..r] = 0 
 | otherwise = minimum' 2019 [mod (i*j) 2019 | i <- [l..r], j <- [l..r], i<j]

minimum' t (a:x) = (null x)?(ans, minimum' ans x) where
  ans = (t<a)?(t,a)
