All tasks
Easystrings

Count Words

Time limit 2 s · Memory 64 MBAcceptance: —Solved by: 0

Statement

You are given one line. Words are separated by one or more spaces; there may also be spaces at the start and the end of the line. Print the number of words.

Examples

Example 1
Input
hello world
Output
2
Example 2
Input
  leading and   trailing  
Output
3

Constraints

  • String length is between 1 and 10^5
Solve this task to unlock the editorial.

AI tutor

Stuck? Get a nudge — the tutor explains the idea, it never hands you the solution.