object Main extends App {
  val Array(k, s) = io.StdIn.readLine().split(' ').map(_.toInt)
  var count = 0
  for (l <- 0 to k) {
    val c = s - l * 2
    if (0 <= c && c <= k) count += 1
    for (r <- l+1 to k) {
      val c = s - (l + r)
      if (0 <= c && c <= k) count += 2
    }
  }
  println(count)
}