let () =
    let main () =
        let l, r = Scanf.sscanf (read_line ()) "%d %d" (fun l r -> l, r) in
        let rec loop_l li count_l acc =
            let rec loop_r rj count_r acc =
                if rj > r || count_r = 2019 then acc else
                    loop_r (rj + 1) (count_r + 1) (min acc ((li * rj) mod 2019))
            in
            if li = r || count_l = 2019 then acc else
                loop_l (li + 1) (count_l + 1) (loop_r (li + 1) 0 acc)
        in
        Printf.printf "%d\n" (loop_l l 0 2019)
    in
    main ()