program answer
  implicit none

  integer :: K, S, i, j, count

  read(*,*) K, S

  if(S==3*K) then
     write(*,*) '1'
     stop
  else if(S==0) then
     write(*,*) '1'
     stop
  end if

  count=0
  do i = 0, K
     do j = 0, min(S-i,K)
        count=count+1
     end do
  end do

  write(*,*) count
  stop
 end program answer