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
  if(S<=K) then
     do i = 0, S
        do j = 0, S-i
           if(S-i-j>=0) then
              count=count+1
           end if
        end do
     end do
     write(*,*) count
     stop
  end if
  
  do i = 0, K
     do j = 0, S-K
        if(j<=S-i.and.S-i-j>=0.and.S-i-j<=K) then
           count=count+1
        end if
     end do
  end do

  write(*,*) count
  stop
 end program answer
     
     
  
