def read_inputs
  inputs = []
  loop do
    input = gets.split(" ").map(&:to_i)
    case input
      when [0, 0] then break
      else inputs << input
    end
  end
  inputs
end

def countWays(n, x)
  [*1..n].product([*1..n], [*1..n])
    .select{|numbers| numbers.inject(:+) == x}
    .select{|numbers| numbers.uniq.length == 3}
    .map{|numbers| numbers.sort}
    .uniq
    .length
end

inputs = read_inputs
puts inputs.map {|i| countWays(*i)}.join("\n")