#K40242. Count the Standalone Word Occurrences

    ID: 26599 Type: Default 1000ms 256MiB

Count the Standalone Word Occurrences

Count the Standalone Word Occurrences

You are given a block of text and a single word. Your task is to count how many times the word appears in the text as a standalone word. The matching should be case-insensitive and only count the occurrences where the word is separated by word boundaries.

In other words, if the given word is w and the text is T, you need to count the number of matches to the regular expression pattern:

b"+w+"b\\b" + w + "\\b

Note that punctuation and other non-alphanumeric characters are considered as boundaries.

Example: Given the text "Python is great and python is dynamic" and the word "python", the answer is 2.

inputFormat

The input consists of two lines:

  1. The first line contains the text string (which may include spaces and punctuation).
  2. The second line contains the word to search for.

outputFormat

Output a single integer representing the number of times the word appears in the text as a standalone term.

## sample
Python is great and python is dynamic
python
2