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