program sumofthreeintegers
  implicit none
  integer :: k, s
  integer :: i, j, c

  read(*,*) k, s

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

  write(*,'(i0)') c
  stop
end program sumofthreeintegers
