Problem:


Score : 200 points

Problem Statement

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 1

2 2

Sample Output 1

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

Sample Input 2

5 15

Sample Output 2

1

The maximum value of X + Y + Z is 15, achieved by one triple of X, Y and Z.



Sample input:
2 2


Sample output:
6

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())

cnt = 0
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x+y+z == S:
        cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
K,S = [int(i) for i in input().split()]

ans = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+k == S:
                ans += 1
            elif i+j+k > S:
                continue

print(ans)

Submission status: Time Limit Exceeded

Solution code:
k,s = map(int,input().split())
ans = 0
for i in range(0,k+1):
  for j in range(0,k+1):
    for l in range(0,k+1):
      if i + j + l == s:
        ans += 1
      else:
        continue
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k,s = list(map(int,input().split()))
ans = [1 for x in range(k+1) for y in range(k+1) for z in range(k+1) if x + y + z == s]
print(len(ans))

Submission status: Time Limit Exceeded

Solution code:
k,s = list(map(int,input().split()))
ans = [x + y + z for x in range(k+1) for y in range(k+1) for z in range(k+1) if x + y + z == s]
print(len(ans))

Submission status: Time Limit Exceeded

Solution code:
K,S= map(int, input().split())
count=0
for X in range(K+1):
    for Y in range(K+1):
        for Z in range(K+1):
            check=X+Y+Z
            if check == S:
                count += 1
                break
print(count)

Submission status: Time Limit Exceeded

Solution code:
k,s = map(int, input().split())
a = []
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            a.append(i+j+l)
b = a.count(s)
print(b)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())

ans = 0
for x in range(0, K+1):
    for y in range(x, K+1):
        for z in range(y, K+1):
            if x + y + z == S:
                if len(set([x, y, z])) == 1:
                    ans += 1
                elif len(set([x, y, z])) == 2:
                    ans += 3
                else:
                    ans += 6

print(ans)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())

ans = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z == S:
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
k,s = map(int,input().split());a=0
for x in range(k+1):
	for y in range(k+1):
		for z in range(k+1):
			if x+y+z == s: a+=1
print(a)

Submission status: Time Limit Exceeded

Solution code:
k, s = [int(i) for i in input().split()]
answer = 0
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x+y+z==s:
        answer += 1
        break

print(answer)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
a = list(range(k+1))
c = 0
for i in a:
    for j in a:
        for k in a:
            if (i+j+k) == s:
                c += 1
print(c)

Submission status: Time Limit Exceeded

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

ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x + y + z == s:
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
ans = 0
for i in range(k + 1):
    for j in range(i + 1):
        for l in range(j + 1):
            if i + j + l == s:
                if i == j == l:
                    ans += 1
                elif i == j or j == l or l == i:
                    ans += 3
                else:
                    ans += 6
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
ans = 0
for i in range(k + 1):
    for j in range(k + 1):
        for l in range(k + 1):
            if i + j + l == s:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

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

cnt = 0

for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i + j + l == s:
                cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import itertools

a,b = map(int,input().split())

c = np.arange(a + 1)
c = list(c)

cou = 0

for i in itertools.product(c,repeat=3):
    if sum(i) == b:
        cou += 1
    else:
        pass

print(cou)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
input_lines=input().split()
K = int(input_lines[0])
S = int(input_lines[1])
M=0
for i in range(K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i+j+k==S:
        if i==j==k:
          M+=1
        elif i==j or j==k:
          M+=3
        else:
          M+=6
print(M)

Submission status: Time Limit Exceeded

Solution code:
def binary_search_list(beSearched,wanted) :
    l = 0
    r = len(beSearched)

    #print("condition = {}".format(r-l))

    while r - l >= 1 :
        s = (l + r) // 2
        #print("l={} r={} s={}".format(l,r,s))
        if beSearched[s] == wanted :
            return True
        if beSearched[s] > wanted :
            r = s
        else :
            l = s + 1

    return False

K,S = (int(_) for _ in input().split())
num = [_ for _ in range(K+1)]
out = 0
for i in range(K+1):
    for j in range(i+1):
        #print(num[:j+1])
        b = binary_search_list(num[:j+1],S - i - j)
        #print("b={} i={} j={} k = {}".format(b,i,j, S- i -j))
        if b :
            if i == j and j == S - i - j:
                out += 1
            elif i == j or j == S - i - j or S -i - j == i:
                out += 3
            else :
                out += 6

print(out)

Submission status: Time Limit Exceeded

Solution code:
K,S = (int(_) for _ in input().split())

out = 0

for x in range(K+1):
    for y in range(x+1):
        for z in range(y+1):
            if x + y + z == S :
                if x == y and y == z :
                    out += 1
                elif x == y or y == z or z == x:
                    out += 3
                else:
                    out += 6

print(out)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K,S = (int(_) for _ in input().split())

out = 0

for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x + y + z == S :
                out += 1

print(out)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())
x,y,z = 0,0,0
ans = 0

for i in range(K+1):
  x = i
  for j in range(S-i+1):
    y = j
    z = S - x - y
    if x + y + z == S and 0 <= x <= K and 0 <= y <= K and 0 <= z <= K:
      ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())
x,y,z = 0,0,0
ans = 0

for i in range(K+1):
  x = i
  for j in range(K+1):
    y = j
    z = S - x - y
    if x + y + z == S and 0 <= x <= K and 0 <= y <= K and 0 <= z <= K:
      ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k,s = map(int, input().split())
ans = 0

for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z == s:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
K,S=map(int,input().split())
count=0
for X in range(K+1) :
    for Y in range(K+1) :
        for Z in range(K+1) :
            if X+Y+Z==S :
                count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())
count = 0
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x + y + z == S:
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
K, S = map(int, input().split())
ans = 0

for X in range(K + 1):
    for Y in range(X, K + 1):
        for Z in range(Y, K + 1):
            if X + Y + Z == S:
                if len(set([X, Y, Z])) == 1:
                    ans += 1
                elif len(set([X, Y, Z])) == 2:
                    ans += 3
                else:
                    ans += 6
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
count = 0

for i in range(k+1):
    for j in range(k+1):
        for m in range(k+1):
            if i+j+m == s:
                count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
K,S = map(int,input().split(" "))
     
s = 0
     
for x in range(K+1):
  if x >S:
    break
  for y in range(K+1):
    if x + y >S:
      break
    for z in range(K+1):
      if x +y +z ==S:
        s +=1
      if x + y + z >S:
        break
     
print(s)

Submission status: Time Limit Exceeded

Solution code:
K,S = map(int,input().split(" "))
 
s = 0
 
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x +y +z ==S:
        s +=1
 
print(s)

Submission status: Time Limit Exceeded

Solution code:
k,s=map(int, input().split())
count=0

for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x+y+z==s:
        count+=1

print(count)

Submission status: Time Limit Exceeded

Solution code:
K,S = map(int,input().split())
ans = 0
for a in range(K+1):
    for b in range(K+1):
        for c in range(K+1):
            if S == a + b + c:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int,input().split())
ans = 0

for i in range(K+1):
  for j in range(K+1):
    if 0<=i<=K and 0<=S-i-j<=K and 0<=j<=K:
      ans += 1
#    print(i, j, S-i-j, ans)
      

print(ans)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int,input().split())
ans = 0

for i in range(K+1):
  for j in range(S+1-i):
    if 0<=i<=K and 0<=S-i-j<=K and 0<=j<=K:
      ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
ans = 0
for x in range(k + 1):
    if x > k:
        break
    for y in range(k + 1):
        if y > k:
            break
        z = s - x - y
        if (z >= 0) & (z <= k):
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, s = map(int, input().split())
res = 0

for i in range(0, n + 1):
    for t in range(0, n + 1):
        for f in range(0, n + 1):
            v = i + t + f
            if v == s:
                res += 1

print(res)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())

cnt = 0
K += 1

for x in range(K):
    for y in range(K):
        for z in range(K):
            if x + y + z == S:
                cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
count=0
k,s=map(int,input().split())
for i in range(k+1):
  for j in range(k+1):
    for m in range(k+1):
      if i+j+m==s:
        count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
count = 0
K, S = map(int, input().split())
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x + y + z == S:
                count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
ans=0
a,b=map(int,input().split())
for s in range(a+1):
    for t in range(a+1):
        for r in range(a+1):
            ans+=(b-s-t-r==0)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# 0 ≦ X, Y, Z ≦ K
# X + Y + Z = S
# 2 ≦ K ≦ 2500
# 0 ≦ S ≦ 3K

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

cnt = 0
# X
for i in range(K + 1):
    if i > S:
        break
    # Y
    for j in range(K + 1):
        if i + j > S:
            break
        # Z
        for k in range(K + 1):
            if i + j + k > S:
                break
            if i + j + k == S:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
# 0 ≦ X, Y, Z ≦ K
# X + Y + Z = S
# 2 ≦ K ≦ 2500
# 0 ≦ S ≦ 3K

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

cnt = 0
# X
for i in range(K + 1):
    # Y
    for j in range(K + 1):
        # Z
        for k in range(K + 1):
            if i + j + k > S:
                break
            if i + j + k == S:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
# 0 ≦ X, Y, Z ≦ K
# X + Y + Z = S
# 2 ≦ K ≦ 2500
# 0 ≦ S ≦ 3K

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

cnt = 0
# X
for i in range(K + 1):
    # Y
    for j in range(K + 1):
        # Z
        for k in range(K + 1):
            if i + j + k > S:
                continue
            if i + j + k == S:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
# 0 ≦ X, Y, Z ≦ K
# X + Y + Z = S
# 2 ≦ K ≦ 2500
# 0 ≦ S ≦ 3K

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

cnt = 0
# X
for i in range(K + 1):
    # Y
    for j in range(K + 1):
        # Z
        for k in range(K + 1):
            if i + j + k == S:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
k,s = map(int,input().split())

c=0

for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z == s:
                c+=1
                
                
print(c)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())

count = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z==S:
                count += 1

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())
ans = 0

for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x + y + z == S:
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
K,S = map(int,input().split())
g = 0
for x in range(0,K+1):
    for y in range(x,K+1):
        for z in range(y,K+1):
            if x+y+z == S:
                if x == y == z:g += 1
                elif x == y or y == z:g += 3
                else:g += 6
print(g)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys

x = [[int(i) for i in input().split()] for j in range(1)]
k = x[0][0]
s = x[0][1]


#k = 5
#s = 15

count = 0
for x in range(k+1):
    if x == s:
        count = count + 1
        break
    for y in range(k+1):
        if s == x + y:
            count = count + 1
            break
        for z in range(k+1):
            if s <= k + x + y:
                count = count + 1
                break
print(count)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys

x = [[int(i) for i in input().split()] for j in range(1)]
k = x[0][0]
s = x[0][1]


#k = 5
#s = 15

count = 0
for x in range(k+1):
    if s < x:
        break
    for y in range(k+1):
        if s < x + y:
            break
        if x + 2*k < s:
            break
        for z in range(k+1):
            if x + y + z == s:
                count = count + 1
                break
            if x + y + k < s:
                break

print(count)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys

x = [[int(i) for i in input().split()] for j in range(1)]
k = x[0][0]
s = x[0][1]


#k = 5
#s = 15

count = 0
for x in range(k+1):
    if s < x:
        break
    for y in range(k+1):
        if s < x + y:
            break
        for z in range(k+1):
            if x + y + z == s:
                count = count + 1
                break
print(count)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys

x = [[int(i) for i in input().split()] for j in range(1)]
k = x[0][0]
s = x[0][1]


#k = 5
#s = 15

count = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x + y + z == s:
                count = count + 1
                break
print(count)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
ans = []
for i in range(k+1):
    for j in range(min(k+1,s-i+1)):
        h = s- i- j
        if 0<= h <= k:
            ans.append([i, j, h])
print(len(ans))

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
ans = []
for i in range(k+1):
    for j in range(min(k+1,s-i+1)):
        for h in range(min(k+1,s-i-j+1)):
            if i + j + h == s:
                ans.append([i, j, h])
                break
print(len(ans))

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
ans = []
for i in range(k+1):
    for j in range(min(k+1,s-i+1)):
        for h in range(min(k+1,s-i-j+1)):
            if i + j + h == s:
                ans.append([i, j, h])
                
print(len(ans))

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
ans = []
for i in range(k+1):
    for j in range(k+1):
        for h in range(k+1):
            if i + j + h == s:
                ans.append([i, j, h])
                break
print(len(ans))

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
ans = []
for i in range(k+1):
    for j in range(k+1):
        for h in range(k+1):
            if i + j + h == s:
                ans.append([i, j, h])
print(len(ans))

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())

counter = 0
for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if S == x + y + z:
                counter += 1
print(counter)

Submission status: Time Limit Exceeded

Solution code:
k,s = map(int,input().split())

count = 0
for x in range(k+1):
	for y in range(k+1):
		for z in range(k+1):
			if x+y + z == s:
				count+=1
				
print(count)

Submission status: Time Limit Exceeded

Solution code:
k, s = (int(i) for i in input().split())
count = 0
for x in range(k+1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int,input().split())
count = 0
start = max(S - 2*K, 0)
for X in range(start,K+1):
    for Y in range(X,K+1):
        for Z in range(Y,K+1):
            if X+Y+Z == S:
                if X == Y and X == Z:
                    count += 1
                elif X == Y and Y != Z:
                    count += 3
                elif Y == Z  and Z != X:
                    count += 3
                else:
                    count += 6

print(count)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
count = 0

for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i + j + l == s:
                count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
count = 0

for i in range(k+1):
    for j in range(k+1):
        for k in range(k+1):
            if i + j + k == s:
                count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
k,s= map(int,input().split())


count = 0

arr = []
for i in range(0,k+1):
    arr.append(i)

def binary_search(arr,i):
    x = arr
    low = 0
    high = len(x)-1
    t = (low + high) // 2 
    # 探索の下限のlowが上限のhighになるまで探索
    # lowがhighに達すると数は見つからなかったということ
    while (low<=high):
        if (i==x[t]):
            break
        elif (i > x[t]):
            low = t + 1
        elif (i < x[t]):
             high = t - 1
        t = (low + high) // 2

    if (i==x[t]):
        return t
    else:
        return -1




for i in range(0,k+1):
    for j in range(0,k+1):
        l = s - i - j
        answer = binary_search(arr,l)
        # print(i,j,l)
        if(answer!=-1):
            # print('clear',i,j,l)
            count += 1


print(count)

Submission status: Time Limit Exceeded

Solution code:
k,s= map(int,input().split())


count = 0

for i in range(0,k+1):
    for j in range(i,k+1):
        for l in range(j,k+1):
            if i + j + l == s and s<= 3*k:
                if i != j and j != l and i != l:
                    count += 6
                elif i == j and j == l:
                    count += 1
                else:
                    count += 3
                # print(count)
                
            


print(count)

Submission status: Time Limit Exceeded

Solution code:
k,s= map(int,input().split())


count = 0

for i in range(0,k+1):
    for j in range(0,k+1):
        for l in range(0,k+1):
            if i + j + l == s and s<= 3*k:
                # print(count)
                count += 1


print(count)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
res = 0
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x + y + z == s:
        res += 1
print(res)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
ans = 0

for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z == s:
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

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


def Weight(x, y, z):
    if len({x, y, z}) == 1:
        return 1
    elif len({x, y, z}) == 2:
        return 3
    elif len({x, y, z}) == 3:
        return 6


counter = 0
for x in range(k+1):
    for y in range(x+1):
        for z in range(y+1):
            if x + y + z == s:
                counter += Weight(x, y, z)

print(counter)

Submission status: Time Limit Exceeded

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

counter = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x + y + z == s:
                counter += 1

print(counter)

Submission status: Time Limit Exceeded

Solution code:
k,s = map(int,input().split())
c = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z==s:
                c += 1
print(c)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())
count = 0
for i in range(K+1):
	for l in range(K+1):
		for m in range(K+1):
			if i + l + m == S:
				count = count + 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())
cnt = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+k == S:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
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 x+y+z == s and 0 <= z <= k:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())
tmp = 0
for x in range(0,(K+1)):
    for y in range(0,(K+1)):
        for z in range(0,(K+1)):
            if x + y + z == S:
                tmp += 1
print(tmp)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())
cnt = 0
for X in range(K + 1):
    for Y in range(K + 1):
        for Z in range(K + 1):
            if X + Y + Z == S:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
k,s=map(int,input().split())
cnt=0
for l in range(k+1):
    for m in range(k+1):
        for n in range(k+1):
            if l+m+n==s and l<=k and m<=k and n<=k:
                cnt+=1
                #print(l,m,n)
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
K, S = map(int, input().split())
ans = 0
for i in range(K + 1):
    if S > 2 * K + i:
        continue
    for j in range(K + 1):
        if S > K + i + j:
            continue
        for k in range(K + 1):
            if i + j + k == S:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())
ans = 0
for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            # print(x, y, z)
            if x + y + z == S:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
K,S = map(int,input().split())
c = 0

for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if (i + j + k) == S:
                c += 1

print(c)

Submission status: Time Limit Exceeded

Solution code:
k,s=map(int,input().split())
ans=0
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if (i+j+l)==s:
                ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
c = 0

for x in range(k+1):
    for y in range(x, k+1):
        for z in range(y, k+1):
            if x+y+z == s:
                if x == y == z:
                    c += 1
                elif x == y or y == z:
                    c += 3
                else:
                    c += 6

print(c)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
c = 0

for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z == s:
                c += 1

print(c)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())
count = 0
for x in range(K + 1):
    if x == S:
        count += 1
        break
    for y in range(K + 1):
        if x + y == S:
            count += 1
            break
        for z in range(K + 1):
            if x + y + z == S:
                count += 1
                break
print(count)

Submission status: Time Limit Exceeded

Solution code:
#全探索(多分TLE)
K, S = map(int, input().split())

ans = 0

for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+k == S:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k,s=map(int,input().split())
hoge = [[a, b, c] for a in range(k + 1) for b in range(k + 1) for c in range(k + 1)]
ans=0
for i in range(len(hoge)):
    if sum(hoge[i]) == s:
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
y = 0

for i in range(k+1):
	for j in range(k+1):
		for h in range(k+1):
			if i+j+h == s:
				y+=1
print(y)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())
X = range(K + 1)
Y = range(K + 1)
Z = range(K + 1)
count = 0
for i in X:
    for p in Y:
        for o in Z:
            if (S - (i + p)) > K:
                break
            if (i + p + o) == S:
                count += 1
            elif (i + p + o) > S:
                break
print(count)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int, input().split())
X = range(K + 1)
Y = range(K + 1)
Z = range(K + 1)
count = 0
for i in X:
    for p in Y:
        for o in Z:
            if (S - (i + p)) > K:
                break
            if (i + p + o) == S:
                count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
k, s = map(int, input().split())
cnt = 0

for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x + y + z == s:
                cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
k,s=map(int,input().split())
ans=0
for x in range(k+1):
  if x>s:break
  for y in range(k+1):
    if x+y>s:break
    for z in range(k+1):
      if x+y+z > s:break
      if x+y+z == s:ans+=1
        
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k,s=map(int,input().split())
ans=0
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x+y+z > s:break
      if x+y+z == s:ans+=1
        
print(ans)

Submission status: Time Limit Exceeded

Solution code:
"""AtCoder"""

K, N = map(int, input().split())

ans = 0

for i in range(K+1):
  for j in range(K+1):
    for k in range(K+1):
      if i + j + k  == N:
        ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
K, S = map(int,input().split())
cnt = 0
for X in range(0, K + 1):
    for Y in range(0, K + 1):
        for Z in range(0, K + 1):
            if X + Y + Z == S:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
#051B
K,S=map(int,input().split())
count=0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if(i+j+k==S):
                count+=1
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k,s=map(int,input().split())
ans=0
if s<=k:
  print((s+1)*(s+2)//2)
  exit()
for i in range(k+1):
  for j in range(i,k+1):
    for l in range(j,k+1):
      if i+j+l==s:
        if i==j and j==l:
          ans+=1
        elif i==j or j==l or l==i:
          ans+=3
        else:
          ans+=6
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k,s=map(int,input().split())
ans=0
for i in range(k+1):
  for j in range(i,k+1):
    for l in range(j,k+1):
      if i+j+l==s:
        if i==j and j==l:
          ans+=1
        elif i==j or j==l or l==i:
          ans+=3
        else:
          ans+=6
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k,s=map(int,input().split())
ans=0
for i in range(k+1):
  for j in range(k+1):
    for l in range(k+1):
      if i+j+l==s:
        ans+=1
print(ans)