Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters.
计算字符串中的段数,其中段定义为非空格字符的连续序列。
Please note that the string does not contain any non-printable characters.
请注意,该字符串不包含任何不可打印的字符。
Example:
Input: "Hello, my name is John"
Output: 5