CSES - Aalto Competitive Programming 2024 - wk9 - Mon - Buzzwords
  • Time limit: 1.00 s
  • Memory limit: 512 MB

Uolevi is writing an article about trumpets for BrassFeed. To attract readers, the text should contain as many buzzwords as possible. Uolevi has been given a list of trending search terms and he is now counting the number of times they appear in his text.

Uolevi's text s consists only of lowercase Latin alphabet and spaces. It does not contain newlines. The list of buzzwords has q terms in it and the total sum of their lengths is Q. The buzzwords consist only of lowercase Latin letters and spaces. Calculate how many buzzwords Uolevi's article contains.

Input

The first line contains a string s, Uolevi's text. The second line contains a single integer q indicating the number of terms. The i-th of next q lines, contains a buzzword buzz_i.

Output

Print the total number of buzzwords the article contains.

Constraints

  • 1 \leq |s| \leq 1000
  • 1 \leq q \leq 10^5
  • 1 \leq Q \leq 2 \times 10^5
  • buzz_i \neq buzz_j if i \neq j
  • |buzz_i| \leq n
  • None of the strings begin or end with a space.
  • None of the strings contain adjacent spaces.

Example 1

Input:

to be fair you have to have a very high iq to understand rick and morty the humor is extremely subtle and without a solid grasp of theoretical physics most of the jokes will go over a typical viewers head
6
quantum mechanics
rick and morty
iq
theoretical physics
ai
philosophical

Output:

4

Example 2

Input:

aaaaaaaaaa
9
a
aa
aaa
aaaa
aaaaa
aaaaaa
aaaaaaa
aaaaaaaa
aaaaaaaaa

Output:

54