#include <stdio.h>
int main (){
	long int  K, S, i, j, l, x, y, z,t=0;
	scanf ("%ld%ld", &K,&S);
	if(3*K>S)
	{
		for (i=K;i>=0;i--)
		{
			x=i;
			if(i>S)
				continue;
			for (j=K;j>=0;j--)
			{
				y=j;
				if(x+y>S) 
					continue;
				for (l=K;l>=0;l--)
				{
					z=l;
					if (x+y+z==S)
					{
						t++;
						break;
					}
				}
			}
		}
	}
	printf ("%ld", t);
	return 0;
}

