#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int k,s;
	while(scanf("%d %d",&k,&s) != EOF){
		int x,y,z;
		int num=0;
		for(x=0; x<=k; x++){
			for(y=0; y<=k; y++){
				for(z=0; z<=k; z++){
					if(x+y+z == s)	num++;
				}
			}
		}
		printf("%d",num);
	}
	return 0;
} 
 
 