def comb_num(n, x)
	result = 0
	for i in 1..n
		for j in i..n
			for k in j..n
				if (i + j + k == x) && ([i, j, k].uniq == [i, j, k])
					puts [i, j, k]
					result+=1
				end
			end
		end
	end
	return result
end

inputs = gets.strip().split(" ").map{|i| i.to_i}
n, x = inputs[0], inputs[1]

until n == 0 && x == 0
	puts comb_num(n, x)
	inputs = gets.strip().split(" ").map{|i| i.to_i}
	n, x = inputs[0], inputs[1]
end
