{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE TemplateHaskell #-}
--atcoder {-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NoImplicitPrelude #-}

import Prelude
import System.IO
import System.Environment
import System.Exit
import Data.List
import Data.Maybe
import qualified Data.Char as Char
import qualified Data.Text as T
import qualified Data.Text.IO as TIO
import qualified Control.Monad
--atcoder import qualified Data.Semigroup
import qualified Data.Map as Map
import qualified Data.Set as Set

readInt :: IO Int
--readInt = read <$> getLine
readInt = getLine >>= (return . read)

readInts :: IO [Int]
readInts = map (read :: String -> Int) <$> words <$> getLine

bf1 :: Int -> Int -> Int
bf1 l r | l >= r = maxBound :: Int
        | otherwise = min cur (bf1 l (r-1))
        where cur = bf2 l r

bf2 :: Int -> Int -> Int
bf2 l r | l >= r = maxBound :: Int
        | otherwise = min ret (bf2 (l+1) r)
        where ret = mod (l*r) 2019

       

solve :: Int -> Int -> Int
solve l r = if r - l + 1 >= 2019
            then 0
            else bf1 l r

main :: IO ()
main = do
    lr <- getLine >>= (return . words) >>= (return . map (read :: String -> Int))
    let l = lr !! 0
    let r = lr !! 1
    let ret = solve l r
    print ret