import scala.io.StdIn.readLine
import scala.math.min

object Main extends App {
  val lines = Iterator.continually(readLine())

  val xs = {
    val xs = for {
      line       <- lines
      Array(n, x) = line.split(" ").map { _.toInt }
    } yield (n, x)

    xs.takeWhile { _ != (0, 0) }
  }

  val results = xs.map(solve)

  results.foreach(println)

  def solve(pair: (Int, Int)): Int = pair match {
    case (n, x) =>
      val m  = min(n, x)
      val zs = for {
        i <- 1 to m
        j <- i + 1 to m
        k  = x - i - j
        if j < k && k <= m
      } yield (i, j, k)

      zs.length
  }
}

