object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  
  val nums = inputs.head.split(" ").map(_.toInt)

  println(solve(nums(0), nums(1)))

  private def solve(k: Int, s: Int): Int = {
    if (3 * k < s) {
      return 0
    }
    var ans = 0

    (0 to k).foreach { i =>
      (0 to k).foreach { j =>
        (0 to k).foreach { n =>
          if((i + j + n) == s) {
            ans = ans + 1
          }
        }
      }
    }

    ans
  }
}