#! /usr/bin/env python3



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

K += 1

cnt = 0

for i in range(min(K, S+1)):

    if i+K*2<=S : continue

    for j in range(min(K, S-i+1)):

        if i+j+K<=S : continue

        cnt += 1

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



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

c = 0

for i in range(max(0, S-K*2), min(K+1, S+1)):

    for j in range(max(0, S-i-K), min(K+1, S-i+1)):

       c += 1

print(c)
#! /usr/bin/env python3
K, S = list(map(int, input().split()))
K += 1
cnt = 0
for i in range(min(K, S + 1)):
    if i + K * 2 <= S:
        continue
    for j in range(min(K, S - i + 1)):
        if i + j + K <= S:
            continue
        cnt += 1
print(cnt)

#! /usr/bin/env python3
K, S = list(map(int, input().split()))
c = 0
for i in range(max(0, S - K * 2), min(K + 1, S + 1)):
    for j in range(max(0, S - i - K), min(K + 1, S - i + 1)):
        c += 1
print(c)

-K += 1 -cnt = 0 -for i in range(min(K, S + 1)): -    if i + K * 2 <= S: -        continue -    for j in range(min(K, S - i + 1)): -        if i + j + K <= S: -            continue -        cnt += 1 -print(cnt) +c = 0 +for i in range(max(0, S - K * 2), min(K + 1, S + 1)): +    for j in range(max(0, S - i - K), min(K + 1, S - i + 1)): +        c += 1 +print(c)