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

main = do
    x <- getLine
    let [l, r] = (map$toInt)$words x

    let p1 = abs (2019 * (l `div` 2019) - l) * abs (2019 * (l `div` 2019) - (l + 1))
    let p2 = abs (2019 * (r `div` 2019) - r) * abs (2019 * (r `div` 2019) - (r - 1))

    let p3 = (l * (l + 1)) `mod` 2019
    let min = minimum[p1, p2, p3]

    print min