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

print((sum(0 <= s - (x + y) <= k for y in range(k + 1) for x in range(k + 1))))

[print(sum(0 <= s - (x + y) <= k for y in range(k + 1) for x in range(k + 1))) for k, s in [map(int, input().split())]]

k, s = list(map(int, input().split()))
print((sum(0 <= s - (x + y) <= k for y in range(k + 1) for x in range(k + 1))))

[
    print(sum(0 <= s - (x + y) <= k for y in range(k + 1) for x in range(k + 1)))
    for k, s in [map(int, input().split())]
]

-k, s = list(map(int, input().split())) -print((sum(0 <= s - (x + y) <= k for y in range(k + 1) for x in range(k + 1)))) +[ +    print(sum(0 <= s - (x + y) <= k for y in range(k + 1) for x in range(k + 1))) +    for k, s in [map(int, input().split())] +]