import scala.io.Source

object Main extends App {
  val lines = Source.stdin.getLines.toList.init

  val count: List[List[String]] =
  for {
    line <- lines
  } yield { val Array(max, sum) = line.split(" ").map(_.toInt)
            val li = List.range(1, max+1)
            for {
              i <- li
              j <- li
              n <- li
              if (i+j+n == sum)
              if (i < j && j < n)
            } yield { s"$i + $j + $n" }
  }

  count.map(_.length).map(println)
}