program prob5
    implicit none
    integer :: K, S
    integer :: x, y
    integer :: ans

    read(*,*) K, S

    ans = 0
    do x = 0, K
        do y = 0, K
            if(x + y >= S - K .and. x + y <= S) then
                ans = ans + 1
            end if
        end do
    end do

    write(*,*) ans
    stop
contains
end program prob5