modreiwa::[Int]->Int
modreiwa xs = (product xs) `mod` 2019

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