let rec for_fold a b v f = if a >= b then v else for_fold (a+1) b (f a v) f
let ans =
  Scanf.scanf "%d %d" @@ fun l r ->
  let l, r = l mod 2019, r mod 2019 in
  if l = 0 && r < l then 0 else
  for_fold l (r+1) max_int @@ fun i a ->
    for_fold (i+1) (r+1) a @@ fun j a -> min a (i * j mod 2019)
let () = Printf.printf "%d\n" ans
