import scala.io.StdIn


object Main extends App {
  val Array(k, s)  = StdIn.readLine.split(" ").map(_.toInt)

  def solve(k: Int, s: Int) : Int  = {
    var cnt = 0
    for(x <- 0 to k; y <- 0 to k; z <- 0 to k) {
      (x + y + z) match {
        case `s` => cnt += 1
        case _ => 0
      }
    }
    cnt
  }
  println(solve(k, s))

}
  


