{-# 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 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

bf :: Int -> Int -> Int
bf l r | l >= r = maxBound :: Int
       | otherwise = mod (a * b) 2019
       where cur = map (\x -> mod x 2019) [l .. r]
             nxt = [bf l (r-1)]
             list = cur ++ nxt
             sl = sort list
             a = sl !! 0
             b = sl !! 1
       

solve :: Int -> Int -> Int
solve l r = if r - l + 1 >= 2019
            then 0
            else bf 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