main :: IO ()
main = do
  [l,r] <- map (read :: String -> Int) . words <$> getLine
  let r_ = mod r 2019
  let l_ = r_ - (r-l)
  print $ ans l_ r_

ans :: Int -> Int -> Int
ans m n = minimum [mod (i*j) 2019 | i <- [m..n], j <- [m..n], i < j]