PROGRAM ATCODER

implicit none
integer :: k,s,x,y,z,ans,i,j

read(*,*) k,s

ans = 0
do i = 0, k, 1
  x = i
  do j = 0, k, 1
    y = j
    z = s - x - y
    if ( z>=0 .and. z<=k ) then
      ans = ans + 1
    end if
  end do
end do

print'(i0)', ans

END PROGRAM ATCODER