counting rectangles