k, s=list(map(int, input().split()))



ans=0

for x in range(0, k+1):

    if x>s:

        break

    for y in range(0, k+1):

        if x+y>s:

            break

        z=s-x-y

        if 0<=z and z<=k:

            ans+=1

            continue

print(ans)
import numpy as np



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

fft_len = 1 << (K * 3).bit_length()



x = np.ones(K + 1)

Fx = np.fft.rfft(x, fft_len)

Fx3 = Fx * Fx * Fx

conv = np.fft.irfft(Fx3, fft_len)



ans = conv[S]

ans = int(ans + 0.5)

print(ans)

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

import numpy as np

K, S = list(map(int, input().split()))
fft_len = 1 << (K * 3).bit_length()
x = np.ones(K + 1)
Fx = np.fft.rfft(x, fft_len)
Fx3 = Fx * Fx * Fx
conv = np.fft.irfft(Fx3, fft_len)
ans = conv[S]
ans = int(ans + 0.5)
print(ans)

-k, s = list(map(int, input().split())) -ans = 0 -for x in range(0, k + 1): -    if x > s: -        break -    for y in range(0, k + 1): -        if x + y > s: -            break -        z = s - x - y -        if 0 <= z and z <= k: -            ans += 1 -            continue +import numpy as np + +K, S = list(map(int, input().split())) +fft_len = 1 << (K * 3).bit_length() +x = np.ones(K + 1) +Fx = np.fft.rfft(x, fft_len) +Fx3 = Fx * Fx * Fx +conv = np.fft.irfft(Fx3, fft_len) +ans = conv[S] +ans = int(ans + 0.5)