program ABC_051_B_SumofThreeIntegers
   implicit none
   integer X, Y, Z, K, S, countN
   read(*, *) K, S
   countN = 0
   do X = 0, K
       do Y = 0, K
	      Z = S - (X + Y)
		  if(X + Y + Z == S) then
			  countN = countN + 1
		  end if
	   end do
   end do
   write(*, *) countN
end program ABC_051_B_SumofThreeIntegers