object Main extends App {
  val input=io.Source.stdin.getLines.toIndexedSeq.head.split(' ').map(_.toInt)
  val K=input(0)
  val S=input(1)
  
  var count=0
  (0 to Math.min(S, K)).foreach{ x =>
    (0 to Math.min(S-x, K)).foreach{ y=>
      if(S-x-y <= K) count += 1
    }
  }
  println(count)
}
