Counting houses by a way a bounding box

Is there a way automatically to count the number of houses in each way inside a bounding box?
The main problem is that I need to associate the number of houses with the way.
Thanks in advance!