You are given two integers K and S.

Three variable X, Y and Z takes integer values satisfying 0≤X,Y,Z≤K.

How many different assignments of values to X, Y and Z are there such that X + Y + Z = S?  

-----Constraints-----
 - 2≤K≤2500 
 - 0≤S≤3K 
 - K and S are integers.  

-----Input-----
The input is given from Standard Input in the following format:
K S

-----Output-----
Print the number of the triples of X, Y and Z that satisfy the condition.

-----Sample Input-----
2 2

-----Sample Output-----
6

There are six triples of X, Y and Z that satisfy the condition:
 - X = 0, Y = 0, Z = 2 
 - X = 0, Y = 2, Z = 0 
 - X = 2, Y = 0, Z = 0 
 - X = 0, Y = 1, Z = 1 
 - X = 1, Y = 0, Z = 1 
 - X = 1, Y = 1, Z = 0

Difficulty: EASY

Solutions:
(k, s) = map(int, input().split())
print(len([2 for z in range(k + 1) for y in range(k + 1) if 0 <= s - y - z <= k]))


(k, s) = map(int, input().split())
cnt = 0
for i in range(k + 1):
	for j in range(k + 1):
		if s - k <= i + j <= s:
			cnt += 1
print(cnt)


(K, S) = map(int, input().split())
kotae = 0
for Z in range(K + 1):
	X_plus_Y = S - Z
	for Y in range(K + 1):
		X = X_plus_Y - Y
		if 0 <= X <= K:
			kotae += 1
print(kotae)


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


(K, S) = map(int, input().split())
count = 0
for i in range(K + 1):
	for j in range(K + 1):
		if 0 <= S - (i + j) <= K:
			count += 1
print(count)


(a, b) = list(map(int, input().split()))
n = 0
for y in range(a + 1):
	for z in range(a + 1):
		p = b - y - z
		if 0 <= p and p <= a:
			n += 1
print(n)


(K, S) = map(int, input().split())
total = 0
count = 0
for x in range(0, K + 1):
	for y in range(0, K + 1):
		if K >= S - x - y and S - x - y >= 0:
			count += 1
print(count)


import os
import sys

def main():
	(K, S) = list(map(int, input().split()))
	ans = 0
	for x in range(K + 1):
		for y in range(K + 1):
			if 0 <= S - x - y <= K:
				ans += 1
	print(ans)

def __starting_point():
	main()
__starting_point()


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


(K, S) = list(map(int, input().split()))
ans = 0
for x in range(0, K + 1):
	for y in range(0, K + 1):
		z = S - x - y
		if 0 <= z and z <= K:
			ans += 1
print(ans)


(K, S) = map(int, input().split())
cnt = 0
for x in range(K + 1):
	for y in range(K + 1):
		z = S - x - y
		if 0 <= z <= K:
			cnt += 1
print(cnt)


def main():
	(stdIn1, stdIn2) = list(map(int, input().split()))
	stdOut = solve(stdIn1, stdIn2)
	print(stdOut)

def solve(k, s):
	pattern = 0
	for x in range(k + 1):
		if x > s:
			break
		for y in range(k + 1):
			if x + y > s:
				break
			z = s - x - y
			if z <= k:
				pattern += 1
	return pattern

def __starting_point():
	main()
__starting_point()


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


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


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

def the_algorithm(k, n):
	count = 0
	for x in range(k + 1):
		for y in range(k + 1):
			z = n - x - y
			if 0 <= z <= k:
				count += 1
	return count
print(the_algorithm(k, n))


import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

def I():
	return int(input())

def F():
	return float(input())

def SS():
	return input()

def LI():
	return [int(x) for x in input().split()]

def LI_():
	return [int(x) - 1 for x in input().split()]

def LF():
	return [float(x) for x in input().split()]

def LSS():
	return input().split()

def resolve():
	(K, S) = LI()
	ans = 0
	for (x, y) in itertools.product(list(range(K + 1)), repeat=2):
		if 0 <= S - (x + y) <= K:
			ans += 1
	print(ans)

def __starting_point():
	resolve()
__starting_point()


(k, s) = map(int, input().split())
ans = 0
for i in range(k + 1):
	for j in range(k + 1):
		if s - (i + j) <= k and s - (i + j) >= 0:
			ans += 1
print(ans)


def main():
	(K, S) = list(map(int, input().split()))
	ans = 0
	for Z in range(0, K + 1):
		if 0 <= S - Z <= 2 * K:
			ans += min(2 * K - (S - Z) + 1, S - Z + 1)
	print(ans)

def __starting_point():
	main()
__starting_point()


(k, s) = map(int, input().split())
count = 0
for X in range(k + 1):
	for Y in range(k + 1):
		Z = s - X - Y
		if k >= Z >= 0:
			count += 1
print(count)


def answer(k: int, s: int) -> int:
	count = 0
	for x in range(k + 1):
		y_max = min(k, s - x)
		y_min = max(0, s - x - k)
		comb = y_max - y_min + 1
		if 0 < comb:
			count += comb
	return count

def main():
	(k, s) = map(int, input().split())
	print(answer(k, s))

def __starting_point():
	main()
__starting_point()


(k, s) = map(int, input().split())
count = 0
for x in range(k + 1):
	for y in range(k + 1):
		z = s - x - y
		if 0 <= z <= k:
			count += 1
print(count)


(K, S) = list(map(int, input().split()))
Sum = 0
for i in range(K + 1):
	for j in range(K + 1):
		if 0 <= S - i - j <= K:
			Sum += 1
print(Sum)


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


(K, S) = map(int, input().split())
ans = 0
for i in range(K + 1):
	for j in range(K + 1):
		x = S - i - j
		if 0 <= x and x <= K:
			ans += 1
print(ans)


def main():
	(K, S) = list(map(int, input().split()))
	ans = 0
	for i in range(K + 1):
		for j in range(K + 1):
			if i + j <= S and S - (i + j) <= K:
				ans += 1
	print(ans)

def __starting_point():
	main()
__starting_point()


def main():
	(K, S) = map(int, input().split())
	ans = 0
	ListK = [i for i in range(K + 1)]
	for x in ListK:
		for y in ListK:
			if 0 <= S - (x + y) <= K:
				ans += 1
	print(ans)

def __starting_point():
	main()
__starting_point()


(K, S) = list(map(int, input().split()))
c = 0
for x in range(K + 1):
	for y in range(K + 1):
		if 0 <= S - (x + y) <= K:
			c += 1
print(c)


(k, s) = list(map(int, input().split()))
c = 0
min_limit = s - k
for i in range(k + 1):
	for j in range(k + 1):
		if i + j <= s and i + j >= min_limit:
			c += 1
print(c)


(k, s) = list(map(int, input().split()))
ans = 0
for i in range(k + 1):
	for j in range(k + 1):
		m = s - i - j
		if 0 <= m <= k:
			ans += 1
print(ans)


import sys
import heapq
from decimal import Decimal
input = sys.stdin.readline
(k, s) = 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)


(k, s) = list(map(int, input().split()))
counter = 0
for x in range(k + 1):
	for y in range(x, k + 1):
		z = s - x - y
		if y <= z <= k:
			if x == y == z:
				counter += 1
			elif x == y or y == z:
				counter += 3
			else:
				counter += 6
print(counter)


(k, s) = map(int, input().split())
total = 0
for i in range(k + 1):
	for j in range(k + 1):
		gen = s - k
		num = i + j
		if num <= s and num >= gen:
			total += 1
print(total)


array = list(map(int, input().split()))
K = array[0]
S = array[1]
count = 0
for i in range(K + 1):
	for j in range(K + 1):
		z = S - i - j
		if z >= 0 and z <= K:
			count += 1
print(count)


def main():
	import sys
	pin = sys.stdin.readline
	pout = sys.stdout.write
	perr = sys.stderr.write
	(K, S) = map(int, pin().split())
	ans = 0
	for x in range(K + 1):
		for y in range(K + 1):
			if 0 <= S - x - y <= K:
				ans += 1
	print(ans)
	return
main()


import sys
from collections import defaultdict

def get_lines():
	return [line for line in sys.stdin]

def get_sum_counts(K):
	cnts = defaultdict(int)
	for i in range(K + 1):
		for j in range(K + 1):
			cnts[i + j] += 1
	return cnts

def main(lines):
	(K, S) = list(map(int, lines[0].split()))
	count = 0
	sum_counts = get_sum_counts(K)
	for z in range(min(K, S) + 1):
		target = S - z
		count += sum_counts[target]
	return count

def __starting_point():
	lines = get_lines()
	res = main(lines)
	print(f'{res}')
__starting_point()


import itertools
url = 'https://atcoder.jp//contests/abc057/tasks/abc057_a'

def main():
	(k, s) = list(map(int, input().split()))
	count = 0
	for (x, y) in itertools.product(range(k + 1), range(k + 1)):
		z = s - x - y
		if 0 <= z <= k:
			count += 1
	print(count)

def __starting_point():
	main()
__starting_point()


(k, s) = map(int, input().split())
ans = 0
for i in range(k + 1):
	num = s - i
	for j in range(min(num + 1, k + 1)):
		if 0 <= num - j <= k:
			ans += 1
print(ans)


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


(K, S) = map(int, input().split())
cnt = 0
for X in range(K + 1):
	for Y in range(K + 1):
		if S - X - Y >= 0 and S - X - Y <= K:
			cnt += 1
print(cnt)


(K, S) = map(int, input().split())
ans = 0
for i in range(K + 1):
	for j in range(K + 1):
		k = S - i - j
		if i + j + k == S:
			if 0 <= k <= K:
				ans += 1
print(ans)


(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 0 <= Z <= K:
			ans += 1
print(ans)


(k, s) = map(int, input().split())
ans = 0
for i1 in range(min(k + 1, s + 1)):
	for i2 in range(0, min(k + 1, s - i1 + 1)):
		if s - (i1 + i2) <= k:
			ans += 1
print(ans)


import sys
(K, S) = map(int, sys.stdin.readline().split())
ans = 0
for x in range(K + 1):
	for y in range(K + 1):
		if 0 <= S - (x + y) <= K:
			ans += 1
print(ans)


(k, s) = list(map(int, input().split()))
counter = 0
for i in range(k + 1):
	counter += max(min(k, s - i) - max(0, s - k - i) + 1, 0)
print(counter)


import sys, math
from itertools import combinations as c, product as p
from collections import deque
sys.setrecursionlimit(10 ** 9)

def si():
	return input()

def ii():
	return int(input())

def fi():
	return float(input())

def lstr():
	return input().split()

def lint():
	return list(map(int, input().split()))

def lint_dec():
	return list(map(lambda x: int(x) - 1, input().split()))

def lnstr(n):
	return [input() for _ in range(n)]

def lnint(n):
	return [int(input()) for _ in range(n)]

def lint_list(n):
	return [lint() for _ in range(n)]
(K, S) = lint()
ans = 0
for i in range(K + 1):
	for j in range(K + 1):
		if 0 <= S - i - j <= K:
			ans += 1
print(ans)


import sys
input = sys.stdin.readline

def main():
	(K, S) = [int(x) for x in input().split()]
	ans = 0
	for x in range(K + 1):
		for y in range(K + 1):
			z = S - x - y
			if z < 0 or z > K:
				continue
			ans += 1
	print(ans)

def __starting_point():
	main()
__starting_point()


(k, s) = map(int, input().split())
count = 0
for x in range(k + 1):
	for y in range(x + 1):
		if x + y > s:
			continue
		else:
			z = s - x - y
			if z > x or z > y:
				continue
			if x == y == z:
				count += 1
			elif x == y or y == z or z == x:
				count += 3
			else:
				count += 6
print(count)


(K, S) = list(map(int, input().split()))
result = 0
for i in range(K + 1):
	for j in range(K + 1):
		if K >= S - (i + j) >= 0:
			z = S - (i + j)
			result += 1
print(result)


(k, s) = [int(x) for x in input().split()]
res = 0
for i in range(k + 1):
	for j in range(k + 1):
		cc = s - i - j
		if 0 <= cc <= k:
			res += 1
print(res)


import itertools as it
(K, S) = map(int, input().split())
counter = 0
for x in range(0, K + 1):
	for y in range(0, K + 1):
		if K >= S - x - y and S - x - y >= 0:
			counter += 1
print(counter)


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


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


(k_num, s_num) = map(int, input().split())
cnt = 0
for x in range(k_num + 1):
	l = s_num - x
	for y in range(k_num + 1):
		z = l - y
		if 0 <= z <= k_num:
			cnt += 1
print(cnt)


(K, S) = map(int, input().split())
ans = 0
x = S // 3 + 1
for i in range(x):
	y = (S - i) // 2 + 1
	for j in range(i, y):
		k = S - i - j
		if k > K:
			continue
		if i == j == k:
			ans += 1
		elif i == j or j == k:
			ans += 3
		else:
			ans += 6
print(ans)


def LI():
	return list(map(int, input().split()))
(K, S) = LI()
ans = 0
for i in range(K + 1):
	for j in range(K + 1):
		if 0 <= S - (i + j) <= K:
			ans += 1
print(ans)


import sys

def solve(K: int, S: int):
	ans = 0
	for x in range(K + 1):
		for y in range(K + 1):
			if 0 <= S - x - y <= K:
				ans += 1
	return ans

def main():

	def iterate_tokens():
		for line in sys.stdin:
			for word in line.split():
				yield word
	tokens = iterate_tokens()
	K = int(next(tokens))
	S = int(next(tokens))
	print(solve(K, S))

def test():
	import doctest
	doctest.testmod()

def __starting_point():
	main()
__starting_point()


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


(a, b) = input().split()
a = int(a)
b = int(b)
c = 0
for i in range(a + 1):
	for k in range(a + 1):
		if b - a <= i + k <= b:
			c = c + 1
print(c)