let k, s = Scanf.scanf " %d %d" @@ fun a b -> a, b
let ans = ref 0
let _ =
  for x = 0 to k do
    for y = 0 to k do if 0 <= s - x - y && s - x - y <= k then incr ans done done;
  Printf.printf "%d\n" !ans