# -*- coding: utf-8 -*-

                   

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

cnt = 0



for X in range(0, K+1):

     for Y in range(0, K+1):

         if 0<=S-X-Y and S-X-Y<=K:

             cnt += 1

print(cnt)
# -*- coding: utf-8 -*-

k, s  = list(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 -*-
K, S = list(map(int, input().split()))
cnt = 0
for X in range(0, K + 1):
    for Y in range(0, K + 1):
        if 0 <= S - X - Y and S - X - Y <= K:
            cnt += 1
print(cnt)

# -*- coding: utf-8 -*-
k, s = list(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)

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