import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [l, r] <- getIntList
    let r' = min r (l + 2018)
    let lr = map (`mod` 2019) [l..r']
    print $ minimum [ mod2019 (lr !! i) (lr !!j)|i <- [0..(length lr - 2)], j <- [i+1..(length lr - 1)]]

mod2019 n m = fm $ (fm n) * (fm m)
    where fm x = x `mod` 2019