import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val k, s = sc.nextInt
  var res = 0
  for (x <- 0 to k;
       y <- 0 to x;
       z <- 0 to y)
  {
    if (x + y + z == s) {
           if (x == y && y == z) res += 1
      else if (x == y || y == z) res += 3
      else res += 6
    }
  }
  println(res)
}
