QOJ.ac

QOJ

Limite de temps : 2.0 s Limite de mémoire : 512 MB Points totaux : 100 Hackable ✓

#9578. Falling in Love with Dictionaries

Statistiques

Xiao Xing found that he couldn't solve even the simplest problem, so he started reading the English novel he brought with him.

Xiao Xing already knows $n$ words (case-insensitive). While reading the novel, whenever he encounters a word he does not know, he looks it up in a dictionary. Xiao Xing has a good memory and can remember every word he looks up. However, he is not very clever; he cannot recognize different forms of the same word and treats them as different words. For example, "accept" and "accepted" will be treated by Xiao Xing as two different words.

Given that Xiao Xing has enough time to finish the entire novel, how many times does he need to look up the dictionary during the reading process?

Input

The first line contains the text of the novel. The length of the text does not exceed $5 \times 10^6$, and it contains only lowercase English letters, spaces, and 4 types of punctuation (',', '.', '!', '?'). All words in the text may have their first letter capitalized or lowercase, and all letters other than the first are lowercase. Words within the same sentence are separated by single spaces. Punctuation marks always appear immediately after a word, and except for the last punctuation mark at the end of the line, they are followed by a space.

The second line contains an integer $n$ ($0 \le n \le 100$), representing the number of words Xiao Xing already knows.

The third line contains $n$ words separated by single spaces, each with a length not exceeding 20, containing only lowercase letters (words may be repeated).

Output

Output a single integer, the number of times Xiao Xing needs to look up the dictionary.

Examples

Input 1

I love Liaoning. Love Dalian!
1
love

Output 1

3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.