implicit none
integer :: k,s,count,y,x
read(5,*) k,s
count=0

do y = 0, k
do x = 0, k
   if (x + y <= s + k .and. s-x-y>=0 .and. s-x-y<=k) then
      count=count+1
   endif
enddo
enddo
write(6,"(i0)") count
end
