program sample
    implicit none
  
    integer(8) :: i,j,m,n,k,s
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) k,s
    m=0
    do i=0,k
        do j=0,k
            if (s-i-j<=k .and. s-i-j>=0)then
                m=m+1
            end if
        end do
    end do
    write(*,*) m
  
    stop
end program sample
  

