lisp to count polyline ends

Hi all
I have a drawing of a network of road centrelines as a series of polylines. I need to count up the number of dead ends, and separately the number of 2,
3 or 4 way intersections. At an intersection typically, there are a number (2-4) of these polylines ending at the same point.
I guess what I'm chasing is a way of doing this by lisp; the drawing I have is for large areas of a city and thus would take a very long time to count by hand; I imagine a lisp that inserts one type of block anywhere that more than one polyline ends at one point, and another type block anywhere where only one polyline ends at that point. Then I can just count the blocks. I'm on AutoCAD 2004 and 2007.
Is this possible? Does anyone have a lisp that already does this or could be easily modded to do it? Or is there another clever way to do this that I'm not thinking about?
David M
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
Add image file
Upload is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.