# coding: utf-8

import time

import re

import math

import fractions



def main():

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

    count=0

    for x in range(0,K+1):

        for y in range(0,K+1):

            if(x+y>S):break

            if S-x-y<=K and S-x-y>=0:

                count+=1

    print(count)

start=time.time()

main()

#print("処理速度 {}sec".format(time.time()-start))

#A=list(map(int,input().split()))

#A,B,C=map(int,input().split())

#n=int(input())



# coding: utf-8

import time

import re

import math

import fractions



def main():

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

    count=0

    for x in range(0,K+1):

        for y in range(0,K+1):

            if S-x-y<=K and S-x-y>=0:

                count+=1

    print(count)

start=time.time()

main()

#print("処理速度 {}sec".format(time.time()-start))

#A=list(map(int,input().split()))

#A,B,C=map(int,input().split())

#n=int(input())



# coding: utf-8
import time
import re
import math
import fractions


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


start = time.time()
main()
# print("処理速度 {}sec".format(time.time()-start))
# A=list(map(int,input().split()))
# A,B,C=map(int,input().split())
# n=int(input())

# coding: utf-8
import time
import re
import math
import fractions


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


start = time.time()
main()
# print("処理速度 {}sec".format(time.time()-start))
# A=list(map(int,input().split()))
# A,B,C=map(int,input().split())
# n=int(input())

-            if x + y > S: -                break