Here is an overview of the number of squares of each size, as they are present in the figure:
9x9: 22 - 2 = 2 8x8: 32 - 2 = 7 7x7: 42 - 2 = 14 6x6: 52 - 2 = 23 5x5: 62 - 2 = 34 4x4: 72 - 2 = 47 3x3: 82 - 2 = 62 2x2: 92 - 2 = 79 1x1: 102 - 2 = 98 ----------------- + Total: 366 squares.