program sum_of_three_integers
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: k,s,x,y,z,ans

    ans=0
    read*, k,s

    do x=0,k
        do y=0,k
            z = s-x-y
            if (0<=z .and. z<=k) ans=ans+1
        end do
    end do

    print'(i0)', ans
end program sum_of_three_integers