let () = Scanf.scanf "%d %d" (fun k s ->
  let arr = Array.init (k+1) (fun i -> i) in
  Array.fold_left (fun a i ->
    let b = Array.fold_left (fun a j -> if 0 <= s-i-j && s-i-j <= k then a+1 else a) 0 arr
    in a+b) 0 arr) |> Printf.printf "%d\n"
