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

# problem B



k, s = list(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 and z <=k:

            ans = ans+1



print(ans)
#!/usr/bin/env python



def main():

    k, s = list(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()

    

# -*- coding: utf-8 -*-
# problem B
k, s = list(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 and z <= k:
            ans = ans + 1
print(ans)

#!/usr/bin/env python
def main():
    k, s = list(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()

-# -*- coding: utf-8 -*- -# problem B -k, s = list(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 and z <= k: -            ans = ans + 1 -print(ans) +#!/usr/bin/env python +def main(): +    k, s = list(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()