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

K += 1

cnt = 0

for i in range(K):

    if i+K*2<=S : continue

    if i>S : continue

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

        if i+j+K<=S : continue

        if i+j>S : break

        cnt += 1

print(cnt)
#! /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)
K, S = list(map(int, input().split()))
K += 1
cnt = 0
for i in range(K):
    if i + K * 2 <= S:
        continue
    if i > S:
        continue
    for j in range(min(K, S - i + 1)):
        if i + j + K <= S:
            continue
        if i + j > S:
            break
        cnt += 1
print(cnt)

#! /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 -for i in range(K): +for i in range(min(K, S + 1)): -        continue -    if i > S: -        if i + j > S: -            break