import scala.io.StdIn._

object Main {
  def main(args: Array[String]) {
    def combinationCount(input: String): Unit = {
      if(input != "0 0") {
        val Array(toNum, sumNum) = input.split(" ").map(_.toInt)
        val combinationSeq = Seq.range(1, toNum + 1).combinations(3)
        val combinationNum = (for (i <- combinationSeq if i.sum == 9) yield i).length
        println(combinationNum)
        combinationCount(readLine())
      }
    }
    
    combinationCount(readLine())
  }
}