to work out the number of squares