import Data.List

calc :: Integer -> Integer -> Integer
calc l r | r <= l = 2019
         | r == l+1 = l*r `mod` 2019
         | l+672 <= r = 0
         | mod r 673 < mod l 673 = 0
         | mod l 673 == 0 = 0
         | otherwise = min (calc l (r-1)) (foldl min 2019 $ map (\x -> x*r `mod` 2019) [l..(r-1)])

main = do
  l:r:_ <- map read . words <$> getLine :: IO [Integer]
  putStrLn . show $ calc l r
