Please solve the programming task below using a self-contained code snippet in a markdown code block.

Given a string s, return the number of segments in the string.
A segment is defined to be a contiguous sequence of non-space characters.
 
Please complete the following python code precisely:
```python
class Solution:
    def countSegments(self, s: str) -> int:
```