import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val k = sc.nextInt
  val s = sc.nextInt


  val res =
  {
    for {
      x <- (0 to k).toArray
      y <- (0 to k).toArray
    } yield (x, y)
  }.foldLeft(0L){case(count,(x,y)) =>
      count + (if(0 <= s - x - y && s - x - y <= k) 1 else 0)
  }

  println(res)
}
