while true
	a,b = gets.chomp.split(" ").map &:to_i
	break if a == 0 and b == 0

	c = 0
	a.times { |i|
		next if i >= b
		a.times { |j|
			break if i+j >= b
			next if j <= i
			a.times { |k|
				break if i+j+k > b
				next if k <= j or i+j+k < b
				c += 1
			}
		}
	}

	puts c
end