open System

let getCombinations (l: 'a list): ('a * 'a) list =
    let comb hd tl =
        List.map (fun x -> (hd, x)) tl
    let rec f acc = function
        | [] -> acc
        | hd :: tl ->
            f (acc @ comb hd tl) tl
    f [] l


[<EntryPoint>]
let main _ =
    let [| l; r |] =
        let splitted = Console.ReadLine().Split(' ')
        splitted |> Array.map Int32.Parse

    let s =
        seq {
            let stop = min r (l + 2019)
            for n in [ l..stop ] do
                yield n
        }

    List.ofSeq s
    |> getCombinations
    |> List.map (fun (a, b) -> (a * b) % 2019)
    |> List.min
    |> printf "%d"

    0 // return an integer exit code
