n, x = gets.split.map(&:to_i)
count = 0

for i in 1..n do
  for e in i..n do
    for q in e..n do
      if i + e + q == x && i != e && e !=q then
        count += 1
      end
    end
  end
end

puts count