private fun readInts() = readLine()!!.split(" ").map { it.toInt() }

fun main(args: Array<String>) {
    val (K, S) = readInts()

    var c = 0
    for (x in 0..K) {
        for (y in 0..K) {
            val z = S - x - y
            if (!(z < 0 || K < z) && x + y + z == S) c++
        }
    }

    println(c)
}