Buggy python submission (verdict: Time Limit Exceeded):
a,b = list(map(int, input().split()))
ans = 0

if 3*a < b:
  print(ans)
elif 3*a == b:
  print(1)
elif 3*a > b:
  for i in range(a+1):
    if i > b:
      break
    elif i == b:
      ans += 1
      continue
    elif i < b:
      if i+2*a < b:
        break
      elif i+2*a == b:
        ans += 1
        continue
      elif i+2*a > b:
        for j in range(a+1):
          if i+j > b:
            break
          elif i+j == b:
            ans += 1
            continue
          elif i+j < b:
            if i+j+a < b:
              break
            elif i+j+a == b:
              ans += 1
              continue
            elif i+j+a > b:
              for k in range(a+1):
                if i+j+k == b:
                  ans += 1
              
  print(ans)

Fixed submission:
k,s = list(map(int, input().split()))
ans = 0
for x in range(k+1):
  mx = min(k, s-x)
  mn = max(0, s-x-k)
  ans += max(0, mx-mn+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a,b = list(map(int, input().split()))
ans = 0

if 3*a < b:
  print(ans)
elif 3*a == b:
  print(1)
elif 3*a > b:
  for i in range(a+1):
    if i > b:
      continue
    elif i == b:
      ans += 1
      continue
    elif i < b:
      if i+2*a < b:
        continue
      elif i+2*a == b:
        ans += 1
        continue
      elif i+2*a > b:
        for j in range(a+1):
          if i+j > b:
            continue
          elif i+j == b:
            ans += 1
            continue
          elif i+j < b:
            if i+j+a < b:
              continue
            elif i+j+a == b:
              ans += 1
              continue
            elif i+j+a > b:
              for k in range(a+1):
                if i+j+k > b:
                  break
                elif i+j+k == b:
                  ans += 1
              
  print(ans)

Fixed submission:
k,s = list(map(int, input().split()))
ans = 0
for x in range(k+1):
  mx = min(k, s-x)
  mn = max(0, s-x-k)
  ans += max(0, mx-mn+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a,b = list(map(int, input().split()))
ans = 0

if 3*a < b:
  print(ans)
elif 3*a == b:
  print(1)
else:
  for i in range(a+1):
    if i > b:
      continue
    elif i == b:
      ans += 1
      continue
    else:
      if i+2*a < b:
        continue
      elif i+2*a == b:
        ans += 1
        continue
      else:
        for j in range(a+1):
          if i+j > b:
            continue
          elif i+j == b:
            ans += 1
            continue
          else:
            if i+j+a < b:
              continue
            elif i+j+a == b:
              ans += 1
              continue
            else:
              for k in range(a+1):
                if i+j+k > b:
                  continue
                elif i+j+k == b:
                  ans += 1
              
  print(ans)

Fixed submission:
k,s = list(map(int, input().split()))
ans = 0
for x in range(k+1):
  mx = min(k, s-x)
  mn = max(0, s-x-k)
  ans += max(0, mx-mn+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a,b = list(map(int, input().split()))
ans = 0

if 3*a < b:
  print(ans)
else:
  for i in range(a+1):
    if i > b:
      continue
    elif i == b:
      ans += 1
      continue
    else:
      if i+2*a < b:
        continue
      elif i+2*a == b:
        ans += 1
        continue
      else:
        for j in range(a+1):
          if i+j > b:
            continue
          elif i+j == b:
            ans += 1
            continue
          else:
            if i+j+a < b:
              continue
            elif i+j+a == b:
              ans += 1
              continue
            else:
              for k in range(a+1):
                if i+j+k == b:
                  ans += 1
              
  print(ans)

Fixed submission:
k,s = list(map(int, input().split()))
ans = 0
for x in range(k+1):
  mx = min(k, s-x)
  mn = max(0, s-x-k)
  ans += max(0, mx-mn+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a,b = list(map(int, input().split()))
ans = 0

if 3*a < b:
  print(ans)
else:
  for i in range(a+1):
    if i > b:
      continue
    else:
      if i+2*a < b:
        continue
      else:
        for j in range(a+1):
          if i+j > b:
            continue
          else:
            if i+j+a < b:
              continue
            else:
              for k in range(a+1):
                if i+j+k == b:
                  ans += 1
              
  print(ans)

Fixed submission:
k,s = list(map(int, input().split()))
ans = 0
for x in range(k+1):
  mx = min(k, s-x)
  mn = max(0, s-x-k)
  ans += max(0, mx-mn+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a,b = list(map(int, input().split()))
ans = 0

if 3*a < b:
  print(ans)
else:
  for i in range(a+1):
    if i > b:
      continue
    else:
      for j in range(a+1):
        if i+j > b:
          continue
        else:
          if i+j+a < b:
            continue
          else:
            for k in range(a+1):
              if i+j+k == b:
                ans += 1
              
  print(ans)


Fixed submission:
k,s = list(map(int, input().split()))
ans = 0
for x in range(k+1):
  mx = min(k, s-x)
  mn = max(0, s-x-k)
  ans += max(0, mx-mn+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a,b = list(map(int, input().split()))
ans = 0

if 3*a < b:
  print(ans)
else:
  for i in range(a+1):
    if i > b:
      continue
    else:
      for j in range(a+1):
        if i+j > b:
          continue
        else:
          for k in range(a+1):
            if i+j+k == b:
              ans += 1
              
  print(ans)

Fixed submission:
k,s = list(map(int, input().split()))
ans = 0
for x in range(k+1):
  mx = min(k, s-x)
  mn = max(0, s-x-k)
  ans += max(0, mx-mn+1)
print(ans)