import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val k = sc.nextInt()
  val s = sc.nextInt()


  var count = 0L
  for (xi in 0..k) {
    for (yi in 0..k) {
      val last = s - xi - yi
      if (last == 0) {
        count++
        break
      }
      if (last > 0 && last <= k) {
        count++
      }
    }
  }

  println(count)

}
