import Foundation

var input_lines = [String]()
input_lines.append(readLine()!)
let strings = input_lines[0].componentsSeparatedByString(" ")

let K = (Int)(strings[0])!
let S = (Int)(strings[1])!

var counter = 0

for i in 0...K {
    if (S - i) / 2 > K {
        break
    }
    for j in 0...K {
        if (S - j - k) > K {
            break
        }
        for k in 0...K {
            if (i + j + k) == S {
                counter += 1
            }
        }
    }
}

print(counter)
