import sys

def input(): return sys.stdin.readline().strip()

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

c=0

for x in range(k+1):

    if x + 2 * k < s:

        continue

    for y in range(k+1):

        if x + y > s:

            continue

        if x + y + k < s:

            continue

        c += 1

print(c)
import sys

def input(): return sys.stdin.readline().strip()

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

c=0

for x in range(max(0,s-2*k),k+1):

    for y in range(max(0,s-x-k),min(k,s-x)+1):

        c += 1

print(c)
import sys


def input():
    return sys.stdin.readline().strip()


k, s = list(map(int, input().split()))
c = 0
for x in range(k + 1):
    if x + 2 * k < s:
        continue
    for y in range(k + 1):
        if x + y > s:
            continue
        if x + y + k < s:
            continue
        c += 1
print(c)

import sys


def input():
    return sys.stdin.readline().strip()


k, s = list(map(int, input().split()))
c = 0
for x in range(max(0, s - 2 * k), k + 1):
    for y in range(max(0, s - x - k), min(k, s - x) + 1):
        c += 1
print(c)

-for x in range(k + 1): -    if x + 2 * k < s: -        continue -    for y in range(k + 1): -        if x + y > s: -            continue -        if x + y + k < s: -            continue +for x in range(max(0, s - 2 * k), k + 1): +    for y in range(max(0, s - x - k), min(k, s - x) + 1):