import scala.io.StdIn._
object Main extends App{
  val sc = new java.util.Scanner(System.in)
  var ka,s = sc.nextInt
  var ans=0
  for(i <- 0 to ka){
    for(j <- 0 to ka){
      for(k <- 0 to ka){
        if((i+j+k)==s){
         ans+=1
        }
      }
    }
  }
  print(ans)
}