object Main {
  def main(args: Array[String]) = {
    val k = readLine.toInt
    val s = readLine.toInt

    val res = (0 to k).toList.map(x => (0 to k).toList.map(y => (0 to k).toList.map(z => if(x+y+z==s) 1 else 0 ))).flatMap(a=>a).flatMap(a=>a).sum
    println(res)
  }
}