import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List

toInts :: IO [Int]
toInts = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

trunc :: Int -> Int -> (Int, Int)
trunc l r = (l, l + (mod (r - l) 2019))

solver :: Int -> Int -> Int
solver l r =
  if l - r > 2018
    then 0
    else let (l_, r_) = trunc l r
          in minimum [mod (i * j) 2019 | i <- [l_ .. r_], j <- [(i + 1) .. r_]]

main :: IO ()
main = do
  l:r:[] <- toInts
  print $ solver l r