Given a diagram with lines parallel to x axis and y axis, find the number of squares formed by these lines.