local K, S = io.read("*n", "*n")

---x >= y >= z
local x, y, z = 0, 0, 0
if K >= S then
	x = S
elseif 2*K >= S then
	x, y = K, S - K
else
	x, y, z = K, K, S - 2*K
end

local count = 0
local sub_x, sub_y, sub_z = x, y, z
while sub_y >= sub_z do
	while y >= z do
		if x == y and y == z then
			count = count + 1
		elseif x == y or y == z then
			count = count + 3
		else
			count = count + 6
		end
		y, z = y - 1, z + 1
	end

	if sub_x == sub_y + 1 then
		sub_x, sub_z = sub_x - 1, sub_z + 1
	elseif x == sub_y then
		sub_x, sub_y, sub_z = sub_x - 1, sub_y - 1, sub_z + 2
	else
		sub_x, sub_y = sub_x - 1, sub_y + 1
	end
	x, y, z = sub_x, sub_y, sub_z
end

print(count)