object Main {
  def main(args: Array[String]): Unit = {
    val Array(n, x, _*) = io.StdIn.readLine().split(" ").map(_.toInt)

    val count =
      (1 to n - 2).map { i =>
        val v = x - i
        (i + 1 to n.min(v / 2)).count { j =>
          val pair = v - j
          j < pair && pair <= n
        }
      }.sum

    println(count)
  }
}