program ABC051B
    implicit none
    integer(8)::K,S,h,i,j
    integer(8)::result=0

    read(5,*) K,S
    
    do i=0,K
        do j=0,K
            if(S-i-j>=0 .and. S-i-j<=K)then
                result=result+1
            end if
        end do
    end do

    print'(i0)',result
end program ABC051B