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

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

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

    let min = minimum[p1, p2, p3, p4]

    print min