Alice is learning English and wants to keep track of all of the new words she learns. Being a programmer, Alice decides to put all of her words into one string, , where each word is separated by a single underscore character. This is known as Snake Case. Can you determine the number of words in Alice’s string?
Given , print the total number of underscore-delimited words it contains on a new line.
Note: You simply need to count the number of words; do not concern yourself with whether or not the words are distinct.
A single line containing string .
- Each word in consists of one or more lowercase English alphabetic letters.
- All words in are delimited by single underscores (
Print the number of underscore-delimited words in string .
Sample Input 0
Sample Output 0
String contains four words:
Thus, we print on a new line.
You need to check few conditions to solve this question. First you can check if the length of string is greater than zero. Else the answer is always zero. If string length is greater than zero and it does not contains any under score then the answer is one. Else count the under scores and add 1 to get the answer.