Given 9 vertical lines spaced 1 cm and 6 horizontal lines spaced 2 cm , find how many squares are there?
EDIT:
I've thought about a general case and found that the ways to make S sized square in $MxN(M\ge N)$ rectangle is (M-S+1)(N-S+1). Summing this all the way to N is
$$\sum_{S=1}^N (M-S+1)(N-S+1) =\frac{N(N+1)(3M-N-1)}{6} $$
and I'm stuck after this.

Hint: go through the sizes of squares. The smallest is $2 \times 2$ cm. How many ways to choose the top line of a $2 \times 2$ square? How many ways to choose the left side? Now do $4 \times 4$ and on.