ARGF.each do |line|
n, x = line.split.map(&:to_i)
ary = []
(1..n).each do |a|
  (1..n).each do |b|
    (1..n).each do |c|
      if a + b + c == x
        ary << [a,b,c].sort
      end
    end
  end
  puts ary.uniq.count
end