Word Count

Interview

Time limit2sMemory limit128 MB

Summary
Count the number of space-separated words in a string that may have leading or trailing spaces.
Level

Easy2 of 10

Topics
String, Implementation
Solved
No attempts yet

Problem

Given a string consisting of uppercase English letters, lowercase English letters, and spaces, determine how many words it contains. If the same word appears more than once, count each occurrence separately.

Input

The first line contains a string consisting of uppercase English letters, lowercase English letters, and spaces. Its length is at most 1,000,000.

Words are separated by exactly one space. Spaces never appear consecutively, but the string may start or end with a space.

Output

Print the number of words in the string.

Examples3

  1. Example 1

    Input
    The Curious Case of Benjamin Button
    
    Expected output
    6
    
  2. Example 2

    Input
     The first character is a blank
    
    Expected output
    6
    
  3. Example 3

    Input
    The last character is a blank 
    
    Expected output
    6