# (1..n)
# a + b + c = x || a != b, b != c, c != a

ARGF.each do |line|
  n, x  = line.split.map(&:to_i)
  break if n == 0 && x == 0

  ary = []

  (1..n).each do |a|
    (1..n).each do |b|
      (1..n).each do |c|
        a + b + c == x
        ary << [a, b, c]
        ary.combination(3)
      end
    end
  end
end