program main
	implicit none
    integer(8)::k,s,ksmin,i,ans,j
    ans=0
    read(*,*)k,s
    ksmin=min(k,s)
    do i=0,ksmin
    	do j=0,s-i
        	if(s-i-j<=k )then
            	ans=ans+1
            end if
        end do
    end do
    
    write(*,*) ans
    stop
end program main