while true
  n,s=gets.split.map(&:to_i)
  break if n==0&&s==0
  c=0
  for i in 0...9
    for j in (i+1)...9
      for k in (j+1)...9
        if i+j+k==s
          c=c+1
        end
      end
    end
  end
  puts c
end