
object Main {
  def main(args: Array[String]): Unit = {
    val in = new java.util.Scanner(System.in)
    val result = getResult(in)
    print(result)
  }
  def getResult(in:java.util.Scanner):String = {
    val n = in.nextInt()
    val x = in.nextInt()
    if(n == 0 && x ==0){
      return ""
    }
    var count = 0
    for(i <- 1 to n){
      for(j <- i to n){
        for(k <- j to n){
          if(i+j+k == x && i != j &&j!= k){
            count += 1
          }
        }
      }
    }
    return count + "\n" + getResult(in)
  }
}