peterverebics/CodeNet_Python_118 huggingface dataset:
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if 0 <= z <= k and x+y+z == s:
            ans += 1
print(ans)
K,S = map(int, input().split())
count = 0
for x in range(K+1):
    for y in range(K+1):
        z = S-x-y
        if z >=0 and z <=K:
            count += 1
print(count)
k,s=map(int,input().split())
c=0
for i in range(k+1):
  for j in range(k+1):
    if 0<=s-i-j<=k:
      c+=1
print(c)
k, s = map(int, input().split())

ans = 0

for x in range(k + 1):
    for y in range(k + 1):
        z = s - (x + y)
        if z >= 0 and z <= k:
            ans += 1

print(ans)
k, s = map(int, input().split())
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if 0<=z<=k:
            cnt += 1
print(cnt)
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29

def main():
    k,s = map(int,input().split())
    ans = 0
    for i in range(k+1):
        for j in range(k+1):
            if s-i-j<=k and s-i-j>=0:
                ans += 1
    print(ans)
    return

if __name__=='__main__':
    main()
k, s=map(int, input().split())
count=0
for x in range(k+1):
  for y in range(k+1):
    z=s-x-y
    if 0<=z<=k:
      count+=1
      
print(count)
K, S = map(int, input().split())

ans = 0
for x in range(K+1):
    for y in range(K+1):
        if S - x - y <= K and S - x - y >= 0:
            ans += 1

print(ans)
K,S=map(int,input().split())
count=0
for i in range(K+1):
    for j in range(K+1):
        if 0<=S-i-j<=K:
            count+=1
print(count)
k,s = map(int, input().split())

ans = 0
for right in range(max(s-k, 0), min(s+1, 2*k+1)):
  lower = max(0, right-k)
  upper = min(k, right)
  if right % 2 != 0:
    ans += upper - lower + 1
  else:
    ans += upper - lower + 1
print(ans)
K, S = map(int, input().split())
ans = 0
for X in range(K+1):
    for Y in range(K+1):
        if 0 <= S-X-Y <= K:
            ans += 1
print(ans)
k,s = map(int,input().split())
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        if 0 <= s-x-y <= k:
            cnt += 1
print(cnt)
def main():
    K, S = map(int, input().split())
    ans = 0
    for x in range(K + 1):
        for y in range(K + 1):
            z = S - x - y
            if z >= 0 and z <= K:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()
k,s=map(int,input().split())
ans=0
for i in range(k+1):
    for j in range(k+1):
        if i+j<=s and i+j+k>=s:
            ans+=1    
print(ans)
K,S = map(int,input().split())
a = 0

for X in range(K+1):
  for Y in range(K+1):
    if 0<=S-X-Y<=K:
      a+=1

print(a)
K,S = map(int,input().split())
C = 0

for x in range(K+1):
  for y in range(K+1):
    if K>=S-x-y>=0:
      C+=1
        
print(C)
K, S = map(int, input().split())
ans = 0

for x in range(K+1):
    for y in range(K+1):
        if K >= S - x - y >= 0:
            ans += 1
print(ans)
k,s=map(int,input().split())
print(len([1 for z in range(k+1) for y in range(k+1) if 0<=s-y-z<=k]))
K, S = map(int, input().split())

ans = 0
for i in range(K + 1):
  for j in range(K + 1):
    if i + j == S:
      ans += 1
    elif 0 <= S - (i + j) <= K:
      ans += 1
print(ans)
k, s = map(int, input().split())

ans = 0
for x in range(k+1):
  for y in range(k+1):
    z = s - x - y
    if x+y+z != s:
      continue
    if z >= 0 and z <= k:
      ans += 1
      
      
print(ans)
k,s = map(int, input().split())
ans = 0

for x in range(k+1):
  for y in range(k+1):
    if 0<=s-x-y and s-x-y <=k:
      ans+=1
print(ans)
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K, S = map(int, sys.stdin.readline().split())

    ret = 0
    for x in range(K + 1):
        for y in range(K + 1):
            if S - x - y <= K and S - x - y >= 0:
                ret += 1
    print(ret)


if __name__ == '__main__':
    main()
k, s = map(int, input().split())

count = 0
for i in range(k+1):
    for j in range(k+1):
        if i+j+k >= s and s-i-j >= 0:
            count += 1
        else:
            continue

print(count)
K,S=map(int,input().split())
ans=0

for i in range(K+1):
    for j in range(K+1):
        if 0<=S-i-j<=K:
            ans+=1
print(ans)
p = input().split()

k = int(p[0])
s = int(p[1])

x = -1
y = -1
z = 0
answer = 0

for num in range(k+1):
    x += 1
    y = -1
    for n in range(k+1):
        y += 1
        z = s - x - y
        if 0 <= z and z <= k:
            answer += 1
 



print(answer)
K, S = map(int, input().split())
ans = 0
for x in range(K + 1) :
    if x > S :
        continue
    for y in range(K + 1) :
        if 0 <= S - x - y <= K :
            ans += 1
print(ans)
from sys import stdin


def main():
    K, S = [int(x) for x in stdin.readline().rstrip().split()]
    result = 0
    for X in range(K + 1):
        for Y in range(K + 1):
            Z = S - (X + Y)
            if Z < 0:
                break
            if X <= K and Y <= K and Z <= K:
                result += 1
    print(result)


if __name__ == "__main__":
    main()
k, s = map(int, input().split())

cnt = 0
for x in range(k+1):
    for y in range(k+1):
        if k >= s - x - y >= 0:
            cnt += 1
print(cnt)
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(2*K + 1 - s_z)
  else:
    ans.append(s_z + 1)
 
print(sum(ans))
K, S = map(int, input().split())

ans = 0
for x in range(K+1):
    for y in range(K+1):
        if S - x - y <= K and S - x - y >= 0:
            ans += 1
print(ans)
k, s = map(int, input().split())
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if z <= k and z >= 0:
            cnt += 1
print(cnt)
k, s = map(int, input().split())
c=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if 0<=z<=k:
            c += 1
print(c)
K,S=map(int, input().split())
ans=0

for i in range(K+1):
  for j in range(K+1):
    if 0<=S-i-j<=K :
      ans+=1
print(ans)
k,s = [int(x) for x in input().split()]

ans = 0

for i in range(k + 1):
    for j in range(k + 1):
        if 0 <= s - i - j <= k:
            ans += 1
            
print(ans)
k, s = map(int, input().split())
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        if (0 <= s-x-y) and (s-x-y <= k):
            cnt += 1
print(cnt)
K,M=list(map(int,input().split()))
ans = 0
for i in range(K+1):
    for j in range(min(K+1,M-i+1)):
        if M-i-j > K:
            continue
        else:
            ans +=1
print(ans)
k,s = map(int,input().split())

count = 0
for x in range(k+1):
  for y in range(k+1):
    z = s-x-y
    if 0 <= z <= k:
      count += 1
print(count)
#!/usr/bin/env python3
k, s = map(int, input().split())

ans = 0

for i in range(k + 1):
    for j in range(k + 1):
        a = s - i - j
        
        if a >= 0 and a <= k:
            ans += 1

print(ans)
i,j=map(int,input().split())
a=0
for x in range(i+1):
  for y in range(i+1):
    if j-(x+y)<=i:
      if x+y<=j:
        a+=1
print(a)
icase=0
if icase==0:
    k,s=map(int,input().split())
    icnt=0
    for x in range(k+1):
        for y in range(k+1):
            z=s-x-y
            if 0<=z and z<=k:
                icnt=icnt+1
    print(icnt)
k, s = map(int, input().split())

cnt = 0
for x in range(0, k+1):
    for y in range(0, k+1):
        z = s - x - y
        if z < 0 or z > k:
            continue
        cnt +=1
print(cnt)
k, s = map(int, input().split())
count = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if 0 <= z <= k:
            count += 1
print(count)
k, s = map(int, input().split())
count = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if 0 <= z <=k:
            count += 1
print(count)
# Problem B - Sum of Three Integers

K, S = map(int, input().split())

count_num = 0
for x in range(K+1):
    tmp_num = S
    tmp_num = tmp_num - x
    for y in range(K+1):
        tmp_num_2 = tmp_num
        z = tmp_num_2 - y
        if z<=K and z>=0:
            count_num = count_num + 1

print(count_num)
K,S = (int(T) for T in input().split())
Count = 0
for TX in range(0,K+1):
    for TY in range(0,K+1):
        if 0<=(S-TX-TY)<=K:
            Count += 1
print(Count)
K,S = map(int, input().split())


ans = 0
for i in range(K+1):
    for j in range(K+1):
        if S - i - j <= K and S - i - j >= 0:
            ans += 1

print(ans)
K,S=map(int,input().split())

ans=0
for a in range(K+1):
    for b in range(K+1):
        if K>=S-a-b and 0<=S-a-b:
            ans+=1
            
print(ans)
# -*- coding: utf-8 -*-
import math
# 整数の入力
k, s = map(int, input().split())
# 計算
count = 0
for x in range(k+1):
    for y in range(k+1):
        if s >= x + y and s - x - y <= k:
            count += 1
        # for z in range(k+1):
        #     if x + y + z == s:
        #         count += 1
print(count)
k_num, s_num = map(int, input().split())

cnt = 0
for x in range(k_num+1):
    l = s_num - x
    for y in range(k_num+1):
        z = l - y
        if 0 <= z <= k_num:
            cnt += 1

print(cnt)
k, s = map(int, input().split())
ans = 0
for x in range(max(s-2*k, 0), min(s, k)+1):
    for y in range(max(s-x-k, 0), min(s-x, k)+1):
        ans += 1
print(ans)
def solve(K, S):
    import bisect
    count = 0
    z_array = [i for i in range(K+1)]
    for x in range(K+1):
        for y in range(K+1):
                z = S - x - y
                if(z >= 0 and z <= K):count+=1
    return count

def main():
    K, S = map(int, input().split())
    print(solve(K, S))
#print(solve(2, 2))
#print(solve(5, 15))
main()
k,s=map(int,input().split(" "))
count=0
for i in range(k+1):
    for j in range(k+1):
        if 0 <= s-i-j <= k:
            count += 1
                
print(count)
k,s = list(map(int,input().split()))

def fact(n):
  return sum([x for x in range(1,n+1)])

ans = 0
r = 0
for x in range(k+1):
  for y in range(x,k+1):
    if 0 <= s - (x+y) <= k:
      if (x==y):
          ans += 1
      else:
          ans += 2

print(ans)
K, S = map(int, input().split())

res = 0

for X in range(min(S, K), -1, -1):
    for Y in range(min(K, S - X), -1, -1):
        if 0 <= S - X - Y <= K:
            res += 1
print(res)
k,s=map(int,input().split())
count=0
for x in range(0,k+1):
  for y in range(0,k+1):
    z=s-x-y
    if 0<=z<=k:
      count+=1
print(count)
k,s=map(int,input().split())

ans=0

for i in range(k+1):
    for j in range(k+1):
        z=s-(i+j)
        if z>=0 and z<=k:
            ans+=1

print(ans)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import copy


def main():
    K, S = map(int, input().split())
    result = 0
    for x in range(K + 1):
        for y in range(K + 1):
            z = S - x - y
            if 0 > z or z > K:
                continue
            else:
                result += 1

    print(result)


if __name__ == "__main__":
    main()
K, S = map(int, input().split())
count = 0
for x in range(K+1):
    for y in range(min(S-x+1, K+1)):
        if S - x - y <= K:
            count += 1
print(count)
K, S = map(int, input().split())

counter = 0
for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if 0 <= z <= K:
            counter += 1
print(counter)
K, S = map(int, input().split())

ans=0
for i in range(K+1):
    for j in range(K+1):
        if 0<=S-i-j<=K:
            ans+=1

print(ans)
k, s = map(int, input().split())
ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        if 0 <= s - x - y <= k:
           ans += 1
print(ans)
k, s = map(int, input().split())

ans = 0
for x in range(0, k + 1):
    for y in range(0, k + 1):
        z = s - x - y
        if 0 <= z and z <= k:
            ans += 1

print(ans)
k,s = map(int,input().split())

ans = 0

for i in range(k+1):
    for j in range(i,k+1):
        c = s-i-j
        if k >= c and c >=j:
            if i == j and j == c:
                ans += 1
            elif i!=j and j!=c and c!=j:
                ans += 6
            else:
                ans += 3
        
print(ans)
K,S = map(int,input().split())
x,y,z = 0,0,0
n = 0

for i in range(K+1):
    x = i
    for j in range(K+1):
        y = j
        z = S-(x+y)
        if 0 <= z <=K:
            n += 1

print(n)
k, s = map(int, input().split())
ans = 0
for x in range(k + 1):
  for y in range(k + 1):
    if x + y > s:
      break
    z = s - x - y
    if 0 <= z <= k:
      ans += 1
      
print(ans)
k,s=map(int,input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if z>=0 and z<=k:
            ans+=1
print(ans)
k, s = map(int,input().split())

ans = 0
for i in range(k+1):
    for j in range(k+1):
        z = s - i - j
        if 0 <= z <= k:
            ans += 1

print(ans)
# coding = SJIS

k, s = map(int, input().split())
ans = 0

for x in range(0, k + 1):
    for y in range(0, k + 1):
        z = s - x - y
        if 0 <= z and z <= k:
            ans += 1

print(ans)
k,s=[int(x) for x in input().split()]

c=0
for x in range(k+1):
    for y in range(k+1):
        if 0<=s-x-y<=k:
            c=c+1
print(c)
import sys
input = sys.stdin.readline
k,s = map(int,input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        if 0 <= s - x - y <= k:
            ans += 1
print(ans)
from sys import stdin
k,s = map(int,stdin.readline().rstrip().split())
point = 0
for i in range(k+1):
    for j in range(k+1):
        if 0 <= s-(i+j) <= k:
            point += 1
print(point)
K,s=map(int,input().split())
cnt=0
for i in range(K+1):
  if s-i>2*K:
    continue
  for j in range(K+1):
    if s-i-j<0:
      break
    if s-i-j<=K:
      cnt+=1
print(cnt)
a,b=input().split()
a=int(a)
b=int(b)
c=0
for i in range(a+1):
  for k in range(a+1):
    if b-a<=i+k<=b:
      c=c+1
print(c)
k,s = map(int ,input().split())

ans = 0
for x in range(k+1):
  for y in range(k+1):
    if 0 <= s - (x+y) <= k:
      ans += 1
print(ans)
K, S = map(int, input().split())
print(sum(0 <= S - X - Y <= K for X in range(K+1) for Y in range(K+1)))
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-(x+y)
        if z >= 0 and z <= k:
            ans += 1
print(ans)
import sys
input = sys.stdin.readline
 
K,S=map(int,input().split())
 
z = list(range(0,K+1))
ans = []
 
for i in z:
  s_z = S - i
  if s_z < 0:
    pass
  elif K < s_z:
    if (K + 1) > (s_z - K):
      ans.append(K + 1 - (s_z - K))
  else:
    ans.append(s_z + 1)
 
print(sum(ans))
def main():
	K, S = map(int, input().split())
	cnt = 0

	for i in range(K + 1):
		for j in range(K + 1):
			k = S - i - j
			if 0 <= k and k <= K:
				cnt += 1

	print(cnt)

  
if __name__ == "__main__":
  	main()
K, S = map(int, input().split())

ans = 0
for x in range(K+1):
    for y in range(K+1):
        z = S- (x + y)
        if 0 <= z <= K:
            ans += 1

print(ans)
def main():
    k, s = map(int, input().split())
    cnt = 0
    for x in range(k+1):
        for y in range(k+1):
            if s - x - y >= 0 and s - x - y <= k:
                    # print(x, y, s-x-y)
                    cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()
K, S = map(int, input().split())
ans = 0
for X in range(K+1):
    for Y in range(K+1):
        if (S- X - Y >=  0 and S - X - Y <= K):
            ans += 1
print(ans)
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
  for y in range(k+1):
    z = s - x - y
    if z <= k and z >= 0:
      ans += 1
print(ans)
k, s = map(int, input().split())
counter = 0
for x in range(k + 1):
    for y in range(x, k + 1):
        z = s - x - y
        if y <= z <= k:
            if x == y == z:
                counter += 1
            elif x == y or y == z:
                counter += 3
            else:
                counter += 6

print(counter)
k, s = map(int, input().split())
count = 0
for x in range(k+1):
    for y in range(k+1):
        if 0 <= s-x-y <= k:
            count += 1
print(count)
K,S = map(int,input().split())
count = 0
for p in range(K+1):
    for q in range(K+1):
        if S-p-q>=0 and S-p-q <= K:
            count+=1
print(count)
k, s = map(int, input().split())

ans = 0
x_min = max(0, s - k - k) 
x_max = min(k, s)
for x in range(x_min, x_max + 1):
    y_min = max(0, s - x - k)
    y_max = min(k, s - x)
    ans += y_max - y_min + 1
print(ans)
k,s = map(int,input().split())

ans=0
for i in range(k+1):
    for j in range(k+1):
        if 0<=s-i-j<=k:
            ans+=1
print(ans)
# B - Sum of Three Integers
K,S= map(int,input().split())
cnt = 0
for x in range(K+1):
    for y in range(K+1):
        z = S-x-y
        if z>=0 and K>=z:
            cnt+=1
print(cnt)
# -*- coding: utf-8 -*-
K, S = map(int, input().split())

n_int = 0

for z in range(min(K, S)+1):
    for y in range(min(K, S-z)+1):
        if S-y-z <= K:
            n_int += 1

print(n_int)
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit
def solve(k,s):
  res = 0
  for i in range(k+1):
    for j in range(k+1):
      l = s - i - j
      if 0 <= l <= k:
        res += 1

  return res



def main():
  K,S = map(int,input().split())
  # a = list(map(int,input().split()))
  print(solve(K,S))
  return

if __name__ == '__main__':
  main()
# coding: utf-8
# Your code here!
k, s = map(int, input().rstrip().split())
result = 0
for x in range(k+1):
    if 2*k >= s - x:
        for y in range(k+1):
            if s - x - y >= 0 and s - x - y <= k:
                result += 1

print(result)
k, s = map(int, input().split())

result = 0

for i in range(k+1):
    for j in range(k+1):
        if s-i-j <= k and s-i-j >= 0:
            result += 1

print(result)
k, s = map(int, input().split())

ans = 0
for i in range(0,k+1):
  for j in range(0,k+1):
    if i+j <= s and s-(i+j) <= k:
      ans += 1
print(ans)
K, S = list(map(int, input().split()))

count = 0

for i in range(K+1):
    for j in range(K+1):
        if 0 <= S - i - j and S - i - j <= K:
            count += 1

print(count)
k, s = map(int,input().split())
# print(k)
# print(s)

# 組み合わせをカウントする変数
count = 0

# 変数の初期化
x = 0
y = 0
z = 0

for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if z >= 0 and z <= k:
            count += 1

print(count)
k, s = map(int, input().split())
cnt = 0
for i in range(min(k+1, s+1)):
    for j in range(min(k+1, s-i+1)):
        if s-i-j<=k:
            cnt += 1
print(cnt)
K, S = map(int, input().split())
ans = 0
for x in range(K+1):
  for y in range(K+1):
    z = S - x - y
    if 0 <= z <= K:
      ans += 1
print(ans)
k, s = map(int, input().split())
r = 0
for x in range(k + 1):
    for y in range(0, min(s - x + 1, k + 1)):
        z = s - x - y
        if 0 <= z <= k and z + x + y == s:
            r += 1
print(r)
k,s = list(map(int,input().split(" ")))

a = 0

for x in range(0,k+1):
    for y in range(0,k+1):
        z = s - x - y
        if (x + y + z ) ==  s and 0 <= z <= k:
            a += 1
print(a)
K, S = map(int, input().split())

count = 0
for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if 0 <= z <= K:
            count += 1
print(count)
K, S = map(int, input().split())
cnt = 0
for x in range(K+1):
  for y in range(K+1):
    if 0 <= S - x - y <= K:
        cnt += 1
print(cnt)
k,s = map(int,input().split())
ans = 0
for i in range(k+1):
    for j in range(k+1):
        dum = (s - (i + j))
        if dum < 0:
            continue
        if dum <= k:
            ans += 1
print(ans)
k,s=map(int,input().split())
cnt=0
for i in range(min(k,s)+1):
  for j in range(min(k,s-i)+1):
    if s-i-j<=k:
      cnt+=1
print(cnt)
k,s=map(int,input().split())

count=0
for i in range(k+1):
  for j in range(k+1):
    if 0<=s-i-j<=k:
      count+=1
      
print(count)
K, S = map(int, input().split(" "))

count = 0
for i in range(K+1):
    for j in range(K+1):
        k = S -(i+j)
        if k >= 0 and k <= K:
            # print(i, j, k)
            count += 1
print(count)
k,s = map(int, input().split())

cnt = 0
for x in range(k+1):
  for y in range(k+1):
    z = s-x-y
    if 0 <= z <= k:
      cnt += 1
print(cnt)
## coding: UTF-8
s = input().split()
t = [int(p) for p in s]
K = t[0]
S = t[1]
counter = 0

for X in range(K+1):
    for Y in range(K+1):
        if(S-X-Y >= 0 and S-X-Y <=K):
            counter += 1
print(counter)
k, s = map(int,input().split())

ans = 0

for x in range(0,k+1):
    for y in range(0,k+1):
        z = s - x - y
        if 0<=z and z <= k:
            ans += 1

print(ans)
k,s = map(int,input().split())
cnt=0
for i in range(k+1):
    for j in range(k+1):
        if 0<=s-(i+j)<=k:
        
            cnt+=1
print(cnt)
k,s = map(int,input().split())
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        if 0 <= (s-x-y) <= k:
            cnt += 1
print(cnt)
k,s=map(int,input().split())
ans=0
for x in range(k+1):
  for y in range(x,k+1):
    z=s-(x+y)
    if z>k or z<y:
      continue
    if x==y and y==z:
      ans+=1
    elif x==y or y==z or x==z:
      ans+=3
    else:
      ans+=6
print(ans)
k,s = map(int,input().split())
ans = 0
for i in range(0,k+1):
    for j in range(0,k+1):
        z = s-i-j
        if 0<=z<=k:
            ans+=1

print(ans)
def ABC051B(k, s):
    count = 0
    for x in range(k+1):
        for y in range(k+1):
            z = s - x - y
            if 0 <= z <= k:
                count += 1
    print(count)

k, s = map(int, input().split())
ABC051B(k, s)
k,s=map(int,input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        z=s-x-y
        if 0<=z<=k:
            ans+=1
print(ans)
K, S = map(int, input().split())

l = []

for i in range(K + 1):
    l.append(i)

count = 0

for i in l:
    for j in l:
        z = S - i - j
        if 0 <= z and z <= K:
            count += 1

print(count)
k, s = map(int, input().split())
c = 0
for i in range(k+1):
  for j in range(k+1):
    if 0 <= s-i-j <= k:
      c += 1
print(c)
K,S=map(int,input().split())
ans=0
for x in range(K+1):
    for y in range(K+1):
            z=S-x-y
            if 0<=z<=K:
                ans+=1

print(ans)
K,S = map(int,input().split())
count=0
for i in range(K+1):
    for j in range(K+1):
            if 0<=S-i-j<=K:
                count+=1
print(count)
K, S = map(int, input().split())

ans = 0
for x in range(K+1):
    for y in range(K+1):
        z = (S-x-y)
        if (0<=z and z<=K):
            ans+=1

print(ans)
K,S=map(int,input().split())
cnt=0

for X in range(0,K+1):
  for Y in range(0,K+1):
    Z=S-X-Y
    if Z>=0 and Z<=K:
      cnt+=1
      
print(cnt)
import sys
input = sys.stdin.readline
K,S=map(int,input().split())
z=list(range(K+1))
ans=[]
for i in z:
  s_z=S-i
  if s_z<0:
    pass
  elif K<s_z:
    if (K+1)>(s_z-K):
      ans.append(2*K-s_z+1)
  else:
    ans.append(s_z+1)
print(sum(ans))
K,S = map(int, input().split())
ans = 0
for X in range(K+1):
    for Y in range(K+1):
        Z = S - (X + Y)
        if 0 <= Z <= K:
            ans += 1
print(ans)
K, S = [int(i) for i in input().split()]
ans = 0
for i in range(K+1):
    for j in range(K+1):
        if 0 <= S-i-j <= K:
            ans += 1
print(ans)
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

K, S = inm()


def solve():
    count = 0
    for x in range(K + 1):
        for y in range(K + 1):
            z = S - x - y
            if 0 <= z <= K:
                count += 1
    return count


print(solve())
k, s = map(int, input().split())
"""
・Z=S-(X+Y)
・0<=Z<=K
"""
ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        if s >= x + y >= s - k:
            ans += 1
print(ans)
K,S=map(int,input().split())
ans=0
for x in range(0,K+1):
    for y in range(0,K+1):
        if S-(x+y)>=0 and S-(x+y)<=K:
            ans+=1           
print(ans)
k,s=map(int,input().split())
c=0

for i in range(k+1):
  for j in range(min(s-i+1,k+1)):
      if  0<=s-i-j<=k:
        c+=1
print(c)
K, S = map(int, input().split(' '))
count = 0
for x in range(K+1):
    for y in range(K+1):
        if S - x - y <= K and S - x - y >= 0:
            count += 1
print(count)