def f(n, s, max = 10)
  if n == 1
    #p [max, s]
    if max > s and s != 0
      return 1
    else
      return 0
    end
  elsif (max - 1 + max - n) * n  / 2 < s
    return 0
  else
    result = 0
    for i in (s + n * (n + 1) / 2) / (n + 1)...max
      if i <= s
        #p [n, s, max, i]
        result += f(n - 1, s - i, i)
      end
    end
    return result
  end
end
while (n, x = gets.split(" ").map(&:to_i)) != [0,0]
  puts f(3, x, n + 1)
end