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[1] {
//        break
//    }
            for k in 0 ... a[0] {
//            if i + k > a[1] || j + k > a[1] {
//                break
//            }
         //   print(i,j,k)
                if i + j + k == a[1] {
                    count += 1
            }
        }
    }
}
print(count)