#C5. Count Substrings

    ID: 48599 Type: Default 1000ms 256MiB

Count Substrings

Count Substrings

Given a string \(s\) and a list of words, your task is to determine how many words in the list appear as a substring in \(s\). A substring is a contiguous sequence of characters within a string. Formally, for a given word \(w\), if there exists an index \(i\) such that \(s[i, i+|w|-1] = w\), then \(w\) is considered a substring of \(s\).

The input is read from the standard input (stdin) and the answer should be printed to the standard output (stdout). The first line of the input contains the string \(s\). The second line contains an integer \(n\), representing the number of words. This is followed by \(n\) lines each containing one word. Your program should output a single integer: the count of words from the list that are substrings of \(s\).

Example:

Input:
programminginpython
4
pro
python
gramming
java

Output: 3

</p>

inputFormat

The input consists of multiple lines:

  1. The first line contains the string \(s\).
  2. The second line contains an integer \(n\), the number of words.
  3. The following \(n\) lines each contain a word.

All input is provided via stdin.

outputFormat

Output a single integer representing the number of words from the list that appear as a substring in \(s\). The output should be written to stdout.

## sample
programminginpython
4
pro
python
gramming
java
3