// Sum of Three Integers

func main() {
    let ks = readLine()!.split(separator: " ").map{Int($0)!}
    let k = ks[0]
    let s = ks[1]

    var count = 0

    let xmax = min(k, s)
    let xmin = max(0, s - 2 * k)
    for x in xmin...xmax {
        let ymin = max(s - x - k, 0)
        let ymax = min(s - x, k)
        let current = ymax - ymin + 1
        count += current
    }
    print(count)
}

main()