defmodule Main do
  def main do
    IO.gets("")
    |> String.trim()
    |> String.split()
    |> Enum.map(&String.to_integer/1)
    |> process()
    |> IO.puts()
  end
  
  defp process([k, s]) do
    Enum.map(0..k, fn x ->
      Enum.map(0..k, fn y ->
        z = s - x - y
        0 <= z and z <= k
      end)
    end)
    |> List.flatten()
    |> Enum.count(&(&1 == true))
  end
end