fun main(args: Array<String>) {
    val list = readLine()!!.split(" ").map(String::toInt)
    val k = list[0]
    val s = list[1]
    var sum = 0
    for (x in 0..k) {
        for (y in 0..k) {
            val z = s - x - y
            if (0 <= z && z <= k) {
                sum += 1
            }
        }
    }
 
    println(sum)
}