object ABC051B {

  import Competitive._

  val K, S = nextInt
  println(Range.inclusive(0, K).flatMap(i => Range.inclusive(0, K).map(j => (i, j, S - (i + j)))).count(t => t._3 >= 0))
}
object Main extends App{
  ABC051B
}

object Competitive{
  import scala.io.StdIn.readLine

  implicit class ForInt(val self: Int) {
    @inline def fori(from: Int)(body: Int => Unit): Unit = {
      var i = from
      while (i < self) {
        body(i)
        i += 1
      }
    }

    @inline def fori()(body: Int => Unit): Unit = fori(0)(body)

    @inline def times(body: => Unit): Unit = fori(0){_ => body}
  }

  private var tokenizerBack = readLine().split(" ").iterator
  def tokenizer: Iterator[String] = {
    tokenizerBack = if (tokenizerBack.hasNext) tokenizerBack else readLine().split(" ").iterator
    tokenizerBack
  }

  def next: String = tokenizer.next
  def nextInt: Int = next.toInt
  def nextLong: Long = next.toLong
  def nextIntArray(n: Int): Array[Int] = Array.fill(n)(nextInt)
  def nextLongArray(n: Int): Array[Long] = Array.fill(n)(nextLong)
  def nextArray(n: Int): Array[String] = Array.fill(n)(next)
}