stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

#define INF 105



int main()

{

	//freopen("input.txt","r",stdin);

	//freopen("output.txt","w",stdout);

	int n,s;

	scanf("%d%d",&n,&s);

	long long counter=0;

	for(int i=0;i<=n;i++)

	{

        for(int k=0;k<=n;k++)

        {

            int tot=i+k;

            if(s-tot<=n && s-tot>=0)

            {

                counter++;

            }

        }

	}

	printf("%lld\n",counter);

}


// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

	scanf("%d %d", &k, &s);

	for (int x = 0; x <= k; x++) {

		for (int y = 0; y <= k; y++) {

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

	printf("%d\n", ans);

	return 0;	

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

 using namespace std;

 int main(){

 int s,k; 

int count=0;

cin>>k>>s; 

for(int x=0;x<=k;x++) { 

for(int y=0;y<=k;y++) {

 int z=s-(x+y); 

if((z>=0)&&(z<=k)){ 

count ++; 

}

}

}

cout<<count; 

return 0; 

}

// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

	scanf("%d %d", &k, &s);

	for (int x = 0; x <= k; x++) {

		for (int y = 0; y <= k; y++) {

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

	printf("%d\n", ans);

	return 0;	

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

 

int main() {

	int k, s,z, count=0;

scanf("%d %d\n",&k,&s) ;

for(int x=0;x<=k;x++) {

for(int y=0;y<=k;y++) {

z=s-x-y;

if(z>=0&&z<=k) {

count++;

} 

 

}} 

printf("%d\n",count) ;

 

return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

	scanf("%d %d", &k, &s);

	for (int x = 0; x <= k; x++) {

		for (int y = 0; y <= k; y++) {

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

	printf("%d\n", ans);

	return 0;	

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

int main(){

int k,s,z;

cin>>k>>s;

int c=0;

for(int i=0;i<=k;i++){

for(int j=0;j<=k;j++){

	z=s-i-j; 

	if(s==(i+j+z))

if(z>=0&&z<=k)

c+=1;

}}

cout<<c;

return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

	scanf("%d %d", &k, &s);

	for (int x = 0; x <= k; x++) {

		for (int y = 0; y <= k; y++) {

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

	printf("%d\n", ans);

	return 0;	

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
   #include<bits/stdc++.h>

  using namespace std;

  int a[1000000];

  int main()

  {

      int k,s;

      cin>>k>>s;

      for(int i=0;i<=k;i++)

      {

         for(int j=0;j<=k;j++)

         {

             a[5000+i+j]++;

         }

    }

     int sum=0;

     for(int i=0;i<=k;i++)

     {

         int pos=s-i;

        if(pos<0)

         {

             continue;

           }

         sum+=a[5000+pos];

     }

     cout<<sum<<endl;

     return 0;

 }

// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

	scanf("%d %d", &k, &s);

	for (int x = 0; x <= k; x++) {

		for (int y = 0; y <= k; y++) {

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

	printf("%d\n", ans);

	return 0;	

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int main ()

{

	int k,s,count=0;

	cin>>k>>s;

	for (int x=0;x<=k;x++)

	{

		for (int y=0;y<=k;y++){

		

		int z =s-x-y;

		if (z<=k &&z>=0)

		count++;

	}

}

cout<<count<<endl;

}

// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

	scanf("%d %d", &k, &s);

	for (int x = 0; x <= k; x++) {

		for (int y = 0; y <= k; y++) {

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

	printf("%d\n", ans);

	return 0;	

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>



using namespace std;



int main()

{

    int k, s, z , count=0;

    cin >> k>> s;

    for (int x= 0; x<=k; x++){

        for (int y=0;y<=k ; y++ ){

            z=s-x-y;

            if(z>=0 && z<=k){

                count++;



            }

        }

    }

    cout << count;



    return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

	scanf("%d %d", &k, &s);

	for (int x = 0; x <= k; x++) {

		for (int y = 0; y <= k; y++) {

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

	printf("%d\n", ans);

	return 0;	

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstring>

#include<algorithm>

#include<cstdio>

#include<string>

#include<queue>

#include<deque>

#define INF 0x3f3f3f3f

using namespace std;

int main(){

	int k,s;

	

	while(cin>>k>>s){

		int con=0;

		for(int x=0;x<=k;x++){

			for(int y=0;y<=k;y++){

				if(s-x-y<=k&&s-x-y>=0){

					con++;

				}

			}

		}

		cout<<con<<endl;

	}

}


// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;

int main() {

	int k, s, ans = 0; //s表示总和数 k表示相加的数的最大取值  

	scanf("%d %d", &k, &s);

	for (int x = 0; x <= k; x++) {

		for (int y = 0; y <= k; y++) {

			int z = s - (x + y);

			if(z >= 0 && z <= k){

				ans++;

			}	

		}

	}

	printf("%d\n", ans);

	return 0;	

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int k,s,cnt=0;

int main(){

    cin>>k>>s;

    for(int x=0;x<=k;x++){

        for(int y=0;y<=k;y++){

            if(s-x-y>=0&&s-x-y<=k) cnt++;

        }

    }

    cout<<cnt<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

int main()

{

    int i,j,k,ans=0,n,h;

    scanf("%d %d",&k,&n);

    for(i=0;i<=k;i++)

        for(j=0;j<=k;j++)

        {

            h=n-i-j;

            if(h>k) continue;

            else if(h<0) continue;

            else ans++;

        }

    printf("%d\n",ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int k,s,i,j,ans=0;

    scanf("%d %d",&k,&s);

    for(i=0;i<=k;i++)

    {

        for(j=0;j<=k;j++)

        {

            int ij=s-i-j;

            if(ij<=k && ij>=0) ans++;

        }

    }

    printf("%d\n",ans);

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

int main()

{

    int i,j,k,ans=0,n,h;

    scanf("%d %d",&k,&n);

    for(i=0;i<=k;i++)

        for(j=0;j<=k;j++)

        {

            h=n-i-j;

            if(h>k) continue;

            else if(h<0) continue;

            else ans++;

        }

    printf("%d\n",ans);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

	int s,k,sum=0;

	cin>>k>>s;

	for(int i=0;i<=k;i++)

	{

		for(int j=0;j<=k;j++)

		{

			if(s-i-j>=0&&s-i-j<=k)

			{

				sum++;

			}

		}

	}

	cout<<sum;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

int main() {

    int s,k,a,b,c,u=0;

    scanf("%d%d",&k,&s);

    for(a=0;a<=k;a++){

        for(b=0;b<=k;b++){

            c=s-a-b;

            if(c<=k&&a<=k&&b<=k&&c>=0)

            ++u;

        }

    }

    printf("%d\n",u);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

	int ans;

	int k,s;

	scanf("%d%d",&k,&s);

	for(int x=0;x<=k;x++)

	{

		for(int y=0;y<=k;y++)

		{

				if(s-x-y>=0&&s-x-y<=k)

				{

					ans++;

				}

		}

	}

	cout<<ans;

	//printf("%d",ans);

}

// Optimized solution to the same problem (faster):
#include<cstdio>

int main() {

    int s,k,a,b,c,u=0;

    scanf("%d%d",&k,&s);

    for(a=0;a<=k;a++){

        for(b=0;b<=k;b++){

            c=s-a-b;

            if(c<=k&&a<=k&&b<=k&&c>=0)

            ++u;

        }

    }

    printf("%d\n",u);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int k,s,cnt=0;

int main()

{

    cin>>k>>s;

    for(int x=0;x<=k;x++)

    {

        for(int y=0;y<=k;y++)

        {

            if(s-x-y>=0&&s-x-y<=k) cnt++;

        }

    }

    cout<<cnt<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

int main() {

    int s,k,a,b,c,u=0;

    scanf("%d%d",&k,&s);

    for(a=0;a<=k;a++){

        for(b=0;b<=k;b++){

            c=s-a-b;

            if(c<=k&&a<=k&&b<=k&&c>=0)

            ++u;

        }

    }

    printf("%d\n",u);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

	int x,y,z,k,s;

	cin>>k>>s;

	int ans=0;

	for(x=0;x<=k;x++)

	{

		for(y=0;y<=k;y++)

		{

			z=s-x-y;

			if(z>=0&&z<=k)

			{

				ans++;

			}

		}

	}

	printf("%d",ans);

}

// Optimized solution to the same problem (faster):
#include<cstdio>

int main() {

    int s,k,a,b,c,u=0;

    scanf("%d%d",&k,&s);

    for(a=0;a<=k;a++){

        for(b=0;b<=k;b++){

            c=s-a-b;

            if(c<=k&&a<=k&&b<=k&&c>=0)

            ++u;

        }

    }

    printf("%d\n",u);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int s,k,cnt;

int main(){

	ios::sync_with_stdio;

	cin>>k>>s;

	for(int i=0;i<=k;i++)

		for(int j=0;j<=k;j++){

			int l=s-i-j;

			if(l<=k&&l>=0)cnt++;

		}

	cout<<cnt<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

int main() {

    int s,k,a,b,c,u=0;

    scanf("%d%d",&k,&s);

    for(a=0;a<=k;a++){

        for(b=0;b<=k;b++){

            c=s-a-b;

            if(c<=k&&a<=k&&b<=k&&c>=0)

            ++u;

        }

    }

    printf("%d\n",u);

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int k,s,ans;

int main()

{

    cin>>k>>s;

    for(int x=0;x<=k;x++)

    {

        for(int y=0;y<=k;y++)

        {

            if(s-x-y>=0&&s-x-y<=k)

			ans++;

        }

    }

    cout<<ans<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int s,i,j,k;

long long n;

int main()

{

	scanf("%d%d",&k,&s);

	for(i=0;i<=k;i++) for(j=0;j<=k;j++) if(s>=i+j&&s<=i+j+k) n++;

	printf("%lld",n);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int k,s,ans;

int main(void)

{

	scanf("%d%d",&k,&s);

	for(int x=0;x<=k;x++) for(int y=0;y<=k;y++) if(s-x-y>=0&&s-x-y<=k) ans++;

	printf("%d",ans);

}

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int s,i,j,k;

long long n;

int main()

{

	scanf("%d%d",&k,&s);

	for(i=0;i<=k;i++) for(j=0;j<=k;j++) if(s>=i+j&&s<=i+j+k) n++;

	printf("%lld",n);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int k, s, ans;

int main ()

{

	cin>>k>>s;

	for(int i=0;i<=k;i++)

	{

		for(int j=0;j<=k;j++){

			int f=s-i-j;

            if(f<=k&&f>=0) ans++;

		}

			

	}

	

	cout<<ans<<"\n";

	return 0;

}  

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int s,i,j,k;

long long n;

int main()

{

	scanf("%d%d",&k,&s);

	for(i=0;i<=k;i++) for(j=0;j<=k;j++) if(s>=i+j&&s<=i+j+k) n++;

	printf("%lld",n);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int k,s,j,i,ans,ij;

int main()

{



    cin>>k>>s;

    for(i=0;i<=k;i++)

    {

        for(j=0;j<=k;j++)

        {

            ij=s-(j+i);

            if(ij<=k&&ij>-1)++ans;

        }

    }

    cout<<ans<<'\n';

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int s,i,j,k;

long long n;

int main()

{

	scanf("%d%d",&k,&s);

	for(i=0;i<=k;i++) for(j=0;j<=k;j++) if(s>=i+j&&s<=i+j+k) n++;

	printf("%lld",n);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



int k,s,ans;



int main()

{

	cin>>k>>s;

	for(int i=0;i<=k;i++)

		for(int j=0;j<=k;j++)

			if (s-i-j<=k&&s-i-j>=0) ans++;

	cout<<ans<<endl;			

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#define ri register int

int k,s,t;

main(){

	scanf("%d%d",&k,&s);

	for(ri x=0;x<=k;++x)

		for(ri y=0;y<=k;++y)

			if(s>=x+y&&s<=k+x+y)

				++t;

	printf("%d\n",t);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
//program luogu.AT2281

#include<iostream>

#include<cstdio>

using namespace std;

int k,s,ans;



void DFS(int sum,int cnt){

	if( cnt==2 ){

		if( s-sum>=0 && s-sum<=k )

			ans++;

		return;

	}

	

	for(int i=0;i<=k;i++)

		DFS(sum+i,cnt+1);

}



int main(){

	scanf("%d%d",&k,&s);

	DFS(0,0);

	printf("%d\n",ans);

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#define ri register int

int k,s,t;

main(){

	scanf("%d%d",&k,&s);

	for(ri x=0;x<=k;++x)

		for(ri y=0;y<=k;++y)

			if(s>=x+y&&s<=k+x+y)

				++t;

	printf("%d\n",t);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int k,s,ans;

int main()

{

    cin>>k>>s;

    for(int x=0;x<=k;x++)

    {

        for(int y=0;y<=k;y++)

        {

            if(s-x-y>=0&&s-x-y<=k) ans++;

        }

    }

    cout<<ans<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#define ri register int

int k,s,t;

main(){

	scanf("%d%d",&k,&s);

	for(ri x=0;x<=k;++x)

		for(ri y=0;y<=k;++y)

			if(s>=x+y&&s<=k+x+y)

				++t;

	printf("%d\n",t);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

#define LL long long

namespace io {

  template <typename T> inline void read(T &x) {

    bool flag = false;  char c = getchar();

    while ((c < '0' || c > '9') && c != '-')  c = getchar();

    c == '-' ? flag = true, x = 0 : x = c - '0';

    c = getchar();

    while (c >= '0' && c <= '9')  x = (x << 3) + (x << 1) + c - '0', c = getchar();

    if (flag)  x = -x;

  }

  template <typename T> inline void write(T x) {

    char st[10010];

    int cnt = 0;

    if (x < 0)  x = -x, putchar('-');

    if (x == 0)  putchar('0');

    while (x) { st[++cnt] = x % 10 + 48;  x /= 10; }

    while (cnt) { putchar(st[cnt--]); }

  }

}

using namespace io;

int main() {

    int s, k, ans = 0;

    read(k); read(s);

    for (int i = k; i >= 0; --i) {

        if (i > s) {

            continue;

        }

        for (int j = k; j >= 0; --j) {

            if (i + j > s) {

                continue;

            }

            int t = s - i - j;

            if (t >= 0 && t <= k) {

                ++ans;

            }

        }

    }

    cout << ans << endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#define ri register int

int k,s,t;

main(){

	scanf("%d%d",&k,&s);

	for(ri x=0;x<=k;++x)

		for(ri y=0;y<=k;++y)

			if(s>=x+y&&s<=k+x+y)

				++t;

	printf("%d\n",t);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
# include <bits/stdc++.h>

using namespace std;

int n,k;

int main()

{

    cin>>k>>n;

    int sum=0;

    for(register int i=0;i<=k;i++)

        for(register int j=0;j<=k;j++)

            {

                int m=n-i-j;

                if(m>k||m<0)continue;

                if(i+j+m==n)sum++;

            }

    cout<<sum<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#define ri register int

int k,s,t;

main(){

	scanf("%d%d",&k,&s);

	for(ri x=0;x<=k;++x)

		for(ri y=0;y<=k;++y)

			if(s>=x+y&&s<=k+x+y)

				++t;

	printf("%d\n",t);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

const int N=1e5+5;



int main()

{

	int k,s,l;

	int ans=0;

	cin>>k>>s;

	for(int i=0;i<=k;i++)

		for(int j=0;j<=k;j++){

			l=s-i-j;

			if(l>=0&&l<=k)ans++;

		}

	cout<<ans<<endl;	

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#define ri register int

int k,s,t;

main(){

	scanf("%d%d",&k,&s);

	for(ri x=0;x<=k;++x)

		for(ri y=0;y<=k;++y)

			if(s>=x+y&&s<=k+x+y)

				++t;

	printf("%d\n",t);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int sum;

int main()

{

    int a,b;

    cin>>a>>b;

    int i,j;

    for(int i=0;i<=a;i++)

    for(int j=0;j<=a;j++)

    {

        if(b-i-j>=0&&(b-i-j)<=a)sum++;

    }

    cout<<sum<<endl;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#define ri register int

int k,s,t;

main(){

	scanf("%d%d",&k,&s);

	for(ri x=0;x<=k;++x)

		for(ri y=0;y<=k;++y)

			if(s>=x+y&&s<=k+x+y)

				++t;

	printf("%d\n",t);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

int main()

{

    int k,s;

    cin>>k>>s;

    int ans=0;

    for(int i=0;i<=k;i++)

    {

        for(int j=0;j<=k;j++)

        {

            int ij=s-i-j;

            if(ij<=k && ij >=0)ans++;



        }

    }

    cout<<ans<<endl;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#define ri register int

int k,s,t;

main(){

	scanf("%d%d",&k,&s);

	for(ri x=0;x<=k;++x)

		for(ri y=0;y<=k;++y)

			if(s>=x+y&&s<=k+x+y)

				++t;

	printf("%d\n",t);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<cmath>

#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

    int K,S,res=0;

    scanf("%d%d",&K,&S);

    for(int x=0;x<=K;x++)

        for(int y=0;y<=K;y++)

        {

            int z=S-x-y;

            if(z>=0 && z<=K)res++;

        }

    return 0*printf("%d\n",res);

}

// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;



int main()

{

  int k, s;

  int i;

  long long ans = 0;

  int target;



  scanf("%d %d", &k, &s);



  // exhaustion



  for (i=0; i<=k; i++) {

    target = s - i;

    if (target < 0) break;

    if (target > 2 * k) {

      continue;

    } else if (target >= k) {

      ans += (2 * k) - target + 1;

    } else {

      ans += target + 1;

    }

  }

  printf("%lld\n", ans);

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main(){

	

	int k,s,z;

	int ans;

	cin>>k>>s;

	for(int x=0;x<=k;x++)

	{

		for(int y=0;y<=k;y++)

		{

			z=s-(x+y);

			if(z>=0 && z<=k && x+y+z==s){

			

		

		ans++;

	    	

		}

	}

}

	 cout<<ans;

}

// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;



int main()

{

  int k, s;

  int i;

  long long ans = 0;

  int target;



  scanf("%d %d", &k, &s);



  // exhaustion



  for (i=0; i<=k; i++) {

    target = s - i;

    if (target < 0) break;

    if (target > 2 * k) {

      continue;

    } else if (target >= k) {

      ans += (2 * k) - target + 1;

    } else {

      ans += target + 1;

    }

  }

  printf("%lld\n", ans);

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

int main(){

	int s,k;

	cin>>k>>s;

	int c=0;

	for(int x=0;x<=k;x++){

	for(int y=0;y<=k;y++){

int	z=s-(x+y);

	if(z>=0&&z<=k){

		c++;

	}

	}	

		

	}

	cout<<c;

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;



int main()

{

  int k, s;

  int i;

  long long ans = 0;

  int target;



  scanf("%d %d", &k, &s);



  // exhaustion



  for (i=0; i<=k; i++) {

    target = s - i;

    if (target < 0) break;

    if (target > 2 * k) {

      continue;

    } else if (target >= k) {

      ans += (2 * k) - target + 1;

    } else {

      ans += target + 1;

    }

  }

  printf("%lld\n", ans);

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

int main(){

int k,s,c=0;

cin>>k>>s;

            for(int x=0;x<=k;x++){

                    for(int y=0;y<=k;y++){

                       int z=s-(x+y);

                            if((z>=0)  && (z<=k) ) {

                                if(0<=s<=(k*3)){

                                     if((x+y+z)==s){

                                         c++;



                    }

            }

    }

   }

}cout<<c<<"\n";



}


// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;



int main()

{

  int k, s;

  int i;

  long long ans = 0;

  int target;



  scanf("%d %d", &k, &s);



  // exhaustion



  for (i=0; i<=k; i++) {

    target = s - i;

    if (target < 0) break;

    if (target > 2 * k) {

      continue;

    } else if (target >= k) {

      ans += (2 * k) - target + 1;

    } else {

      ans += target + 1;

    }

  }

  printf("%lld\n", ans);

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main(){

	int k,s,z;

	int ans;

	cin>>k>>s;

	for(int x=0;x<=k;x++)

	{

		for(int y=0;y<=k;y++){

			z=s-(x+y);

			if(z>=0 && z<=k && x+y+z==s){

				ans++;

			}

		}

		}

		cout<<ans;

		

}

// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;



int main()

{

  int k, s;

  int i;

  long long ans = 0;

  int target;



  scanf("%d %d", &k, &s);



  // exhaustion



  for (i=0; i<=k; i++) {

    target = s - i;

    if (target < 0) break;

    if (target > 2 * k) {

      continue;

    } else if (target >= k) {

      ans += (2 * k) - target + 1;

    } else {

      ans += target + 1;

    }

  }

  printf("%lld\n", ans);

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std; 

int main (){

int s,k;

scanf("%d%d",&k,&s);

int c=0,z;

for(int y=0;y<=k;y++){



for(int x=0;x<=k;x++)

{



z=s-(y+x);

if (z>=0&&z<=k)

c++;

}

}

printf("%d",c);

}

// Optimized solution to the same problem (faster):
#include <cstdio>



using namespace std;



int main()

{

  int k, s;

  int i;

  long long ans = 0;

  int target;



  scanf("%d %d", &k, &s);



  // exhaustion



  for (i=0; i<=k; i++) {

    target = s - i;

    if (target < 0) break;

    if (target > 2 * k) {

      continue;

    } else if (target >= k) {

      ans += (2 * k) - target + 1;

    } else {

      ans += target + 1;

    }

  }

  printf("%lld\n", ans);

  return 0;

}


// Fastest known solution for this problem: