Google is the king

Given a string, we would like to know how many words are in the string. We know that all the words are separated by a space ' '. How many words are there in a given string?
The input contains a single line. It might contain some whitespace at the beginning or at the end. You should ignore that.
The program should print the number of words in that line.
Input
Output
Hi, Anna how are you doing?
6
Hello everyone
2
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue