Adds countSpaces method that counts the number of spaces in the string