class Array
	def pluse i
		newArray=[]
		self.each{|num|
			newArray<<num+i
		}
	newArray
	end

	def sum
		sum_n=0
		self.size.times do |i|
			sum_n+=self[i]
		end
	sum_n
	end
end

count=[]
array=[]
n=[]
x=[]

loop do
 	input=STDIN.gets.split(" ")
 	n<<input[0].to_i
 	x<<input[1].to_i
	if(input[0].to_i==0)&&(input[1].to_i==0)
		break
	end
end

def howManyWays(i,n,a,array)
	if i!=a.size-1
		while a[i]<=n
			start=a.slice(i+1,a.size-1)
			howManyWays(i+1,n,a,array)
			a[i]+=1
			b=start.pluse(1)
			a.slice!(i+1,a.size-1)
			a+=b
		end
	else
		while a[i]<=n
			array<<a.dup
			a[i]+=1
		end
	end
	array
end

#2.upto(n) do |i|
#	i=3
0.upto(n.size-2) do |i|
	count[i]=0
	a=(1..3).to_a
	array=howManyWays(0,n[i],a,[])
#end
	array.each do |arr|
		if arr.sum==x[i]
			count[i]+=1
		end
	end
end

count.each do |i|
	puts i
end