let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  List.rev (doit str [])

let rec repl () =
  let l = read_line () in
  match List.map int_of_string (split l ' ') with
  | [] | [_] -> exit 1
  | 0 :: 0 :: _ -> ()
  | n :: x :: _ ->
      let cnt = ref 0 in
      for a = 1 to n - 2 do
        for b = a + 1 to n - 1 do
          let c = x - a - b in
          if b < c && c <= n then cnt := !cnt + 1
        done;
      done;
      Printf.printf "%d\n" !cnt;
      repl ()

let () =
  try repl () with End_of_file -> ()