program answer
  implicit none

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

  read(*,*) K, S

  count=0
  do i = 0, K
     do j = 0, S-i
        if(j<=K.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