output_description: Print the number of the triples of X, Y and Z that satisfy the condition.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      K S
attempt: # from fractions import gcd
  # mod = 10 ** 9 + 7
  # N = int(input())
  # a = list(map(int,input().split()))
  # a,b,c = map(int,input().split())
  # ans = [0] * N
  # math.ceilで切り上げ
  # dp = [[0] * 4 for i in range(3)] #2次元配列初期化
  # dp = [[[0] * 2 for i in range(3)] for j in range(5)]
  # (ord('A'))でASCII出力 Aは65
  import math
  import numpy as np
  import statistics
  import string
  import sys
  from array import array
  from collections import deque
  from functools import wraps
  import time
  
  
  def intinput():
      return int(input())
  
  
  def listintinput():
      return list(map(int, input().split()))
  
  
  def splitintinput():
      return map(int, input().split())
  
  
  def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
      ret = 1
      for i in range(x, y + 1):
          ret = (ret * i) % z
      return ret
  
  
  def isprime(x):
      if x == 1:
          return False
      if x == 2:
          return True
      sq = int(math.sqrt(x))
      for i in range(2, sq + 1):
          if x % i == 0:
              return False
      return True
  
  
  def hcfnaive(
      a, b
  ):  # 最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
      if b == 0:
          return a
      else:
          return hcfnaive(b, a % b)
  
  
  K, S = splitintinput()
  
  time_sta = time.perf_counter()
  ans = 0
  
  for i in range(K + 1):
      for j in range(min(S - i + 1, K + 1)):
          if S - i - j <= K:
              ans += 1
  print(ans)
  
  
  time_end = time.perf_counter()
  # print(time_end - time_sta)
  
problem_description: Statement
  
  You are given two integers K and S.  
  Three variable X, Y and Z takes integer values satisfying 0≤X,Y,Z≤K.  
  How many different assignments of values to X, Y and Z are there such that X +
  Y + Z = S?
samples: [{"input": "2 2", "output": "6\n    \n\nThere are six triples of X, Y and Z that satisfy the condition:\n\n  * X = 0, Y = 0, Z = 2\n  * X = 0, Y = 2, Z = 0\n  * X = 2, Y = 0, Z = 0\n  * X = 0, Y = 1, Z = 1\n  * X = 1, Y = 0, Z = 1\n  * X = 1, Y = 1, Z = 0\n\n* * *"}, {"input": "5 15", "output": "1\n    \n\nThe maximum value of X + Y + Z is 15, achieved by one triple of X, Y and Z."}]