import Control.Applicative
import Data.List

solve _ m1 0 = [m1, 0]
solve _ 0 m2 = [0, m2]
solve [] m1 m2 = [m1, m2]
solve (x:xs) m1 m2 = do
  let x' =  x `mod` 2019
  let (m1':m2':_) = sort [m1, m2, x']
  solve xs m1' m2'

main = do
  [l, r] <- (map read).words <$> getLine :: IO [Int]
  let xs = [l..r]
  print $ (`mod` 2019) $ product $ solve (drop 2 xs) ((xs !! 0) `mod` 2019) ((xs !! 1) `mod` 2019)
