let input = readLine()!.characters.split(" ").map{Int(String($0))!}
var ans = 0
for X in 0...input[0] {
    for Y in 0...input[0] {
        if 0...K ~= input[1]-X-Y {
            ans += 1
        }
    }
}
print(ans)