toInt :: (String -> Int)
toInt x = read x ::Int

chk :: Int -> Int -> Int
chk l r = minimum $ map (\i -> minimum $ map (\j -> (i * j) `mod` 2019) [(i+1)..r]) [l..(r-1)]

main :: IO ()
main = do
    x <- getLine
    let
        [l, r] = (map $ toInt) $ words x
        ml = l `mod` 2019
        mr = r `mod` 2019
        ans = if (r `div` 2019) - (l `div` 2019) >= 1 
            then 0
            else chk ml mr

    print ans
