DMOPC '19 Contest 5 P1 - Conspicuous Cryptic Checklist
View as PDF has spent the weekend hastily preparing DMOPC problems! Unfortunately, he is now behind on several assignments. After rummaging through his backpack, he realizes that he has items. To save space, he records the
-th item as a string,
, on his checklist. He has
upcoming assignments, the
-th of which requires
items to complete,
. If has all
required items, he can complete the
-th assignment. Otherwise, he flunks it. Help him determine how many assignments he can complete!
Constraints
In all subtasks,
where
denotes the length of string
Input Specification
The first line contains two space-separated integers, and
.
The next lines contain a single string,
. It is guaranteed that all the strings will be unique.
The next sections contain a single integer
, followed by
lines each containing a single string,
.
Output Specification
Output a single integer on a single line, the answer to the problem.
Sample Input
3 4
chalk
cheese
charger
1
cheese
2
coins
cash
3
charger
chalk
caffeine
3
cheese
charger
cheese
Sample Output
2
Comments