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: import sys
  
  """テンプレ"""
  
  # 高速
  input = sys.stdin.readline
  
  
  # 1行を空白でリストにする(int)
  def intline():
      return list(map(int, input().split()))
  
  
  # 上のstrヴァージョン
  def strline():
      return list(map(str, input().split()))
  
  
  # 1列に並んだ数
  def intlines(n):
      return [int(input() for _ in range(n))]
  
  
  # 上の文字列ヴァージョン
  def lines(n):
      return [input() for _ in range(n)]
  
  
  # Union-Find木  http://at274.hatenablog.com/entry/2018/02/02/173000
  class UnionFind:
      def __init__(self, n):
          self.par = [i for i in range(n + 1)]
          self.rank = [0] * (n + 1)
  
      # 検索
      def find(self, x):
          if self.par[x] == x:
              return x
          else:
              self.par[x] = self.find(self.par[x])
              return self.par[x]
  
      # 併合
      def union(self, x, y):
          x = self.find(x)
          y = self.find(y)
          if self.rank[x] < self.rank[y]:
              self.par[x] = y
          else:
              self.par[y] = x
              if self.rank[x] == self.rank[y]:
                  self.rank[x] += 1
  
      # 同じ集合に属するか判定
      def same_check(self, x, y):
          return self.find(x) == self.find(y)
  
  
  # 重み付きのUnion-Find木　http://at274.hatenablog.com/entry/2018/02/03/140504
  class WeightedUnionFind:
      def __init__(self, n):
          self.par = [i for i in range(n + 1)]
          self.rank = [0] * (n + 1)
          # 根への距離を管理
          self.weight = [0] * (n + 1)
  
      # 検索
      def find(self, x):
          if self.par[x] == x:
              return x
          else:
              y = self.find(self.par[x])
              # 親への重みを追加しながら根まで走査
              self.weight[x] += self.weight[self.par[x]]
              self.par[x] = y
              return y
  
      # 併合
      def union(self, x, y, w):
          rx = self.find(x)
          ry = self.find(y)
          # xの木の高さ < yの木の高さ
          if self.rank[rx] < self.rank[ry]:
              self.par[rx] = ry
              self.weight[rx] = w - self.weight[x] + self.weight[y]
          # xの木の高さ ≧ yの木の高さ
          else:
              self.par[ry] = rx
              self.weight[ry] = -w - self.weight[y] + self.weight[x]
              # 木の高さが同じだった場合の処理
              if self.rank[rx] == self.rank[ry]:
                  self.rank[rx] += 1
  
      # 同じ集合に属するか
      def same(self, x, y):
          return self.find(x) == self.find(y)
  
      # xからyへのコスト
      def diff(self, x, y):
          return self.weight[x] - self.weight[y]
  
  
  """ここからメインコード"""
  
  k, s = intline()
  r = range
  ans = 0
  for x in r(k + 1):
      for y in r(k + 1):
          if x + y <= s and s - x - y <= k:
              ans += 1
  print(ans)
  
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."}]