Counting spaces

How could I count the spaces in a chain?