def ans (num, total, amax)
  if(total<=0)
    0
  elsif(num==1)
    if(total<=amax)
      1
    else
      0
  else
    sum=0
    for i in 1..amax do
      sum+=ans(num-1,total-i,amax)
    end
    sum
  end
end
      
  

while(true)
  a,b=gets.split(" ")
  if(a==0&&b==0) then
    break
  end
  d=ans(3 b a)
  puts(d)
end

  