Chess Board: How to find Number of Squares and Rectangles