modreiwa::[Int]->Int
modreiwa xs = (foldl (*) 1 xs) `mod` 2019

main::IO ()
main = do
    [l,r] <- map read . words <$> getLine
    let ij = [[i,j]| i<-[l..r],j<-[i+1..r]]
    let ans = minimum $ map modreiwa ij
    print ans