import Foundation
let a = readLine()!.split(separator: " ").map({Int($0)!})
var count = 0
for i in 0 ... a[0] {

    for j in 0 ... a[0] {
    if i + j > a[0] {
        break
    }
            for k in 0 ... a[0] {
                if i + j + k == a[1] {
                    count += 1
            }
        }
    }
}
print(count)