import scala.io.StdIn

object Main{
  def main(args: Array[String]){
    val num = StdIn.readLine().split(" ").map(_.toInt)
    var count = 0

    for(i <- 1 to num(0)){
      for(j <- i+1 to num(0)){
         for(k <- j+1 to num(0)){
           if(i + j + k == num(1)){
             count += 1
           }
         }
      }
    }
    if(num(0) > 0){
      println(count)
    }
  }
}