import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (l : r : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  print $ f l r

f :: Int -> Int -> Int
f l r | p 673 && p 3 = 0
      | otherwise = (l * (l + 1)) `mod` 2019
  where
    p :: Int -> Bool
    p d = l `div` d < (r + 1) `div` d

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n
