#C9959. Count Occurrences of a Word
Count Occurrences of a Word
Count Occurrences of a Word
You are given a series of sentences and a target word. Your task is to count the total occurrences of the target word in all the sentences, regardless of letter case. For example, if a sentence contains World
in any mix of uppercase or lowercase letters (e.g. world
, WORLD
, etc.), it should be counted as an occurrence.
Input is provided via standard input (stdin) and output should be printed to standard output (stdout).
Note: Word matching is case-insensitive and words are separated by whitespace.
Example:
Input:
1
Hello world
world
Output:
1
inputFormat
The first line contains an integer n representing the number of sentences. The next n lines each contain a sentence. The last line contains the target word to search for.
Input Format:
n
sentence_1
sentence_2
...
sentence_n
target_word
outputFormat
Output a single integer which is the total number of occurrences of the target word in the given sentences. The matching should be done case-insensitively.
## sample1
Hello world
world
1