import scala.io.Source

object Main extends App {
  val Array(max, sum) = Source.stdin.getLines.toList.head.split(" ").map(_.toInt)

  val li = List.range(1, max+1)
  val count =
    for {
      i <- li
      j <- li
      n <- li
      if (i+j+n == sum)
      if (i < j && j < n)
    } yield { s"$i + $j + $n" }

  println(count.length)
}