Method to count total number of spaces