let split c s = (
    let res = ref [] in
    let i = ref 0 in
    let n = String.length s in
    while !i < n do
      let j = !i in
      while !i < n && s.[!i] <> c do i := !i + 1 done;
      res := String.sub s j (!i - j) :: !res;
      i := !i + 1;
    done;
    List.rev !res
  );;

let rec range a b = if a > b then [] else a :: range (a + 1) b;;

let read_ints () = read_line () |> split ' ' |> List.map int_of_string;;
let inf = 1000000000;;

let [n; l] = read_ints ();;
let a = range 0 (n - 1) |> List.map (fun i -> l + i);;
let s = List.fold_left ( + ) 0 a;;
let ans = List.fold_left (fun x y -> min x (abs y, s - y)) (inf, inf) a;;
print_int (snd ans);;
print_newline ();;
