Navi's Party

0

0 votes
Map, Implementation, Data Structures, Easy-Medium, Greedy algorithm, Approved
Problem

Navi's party is going on and there are many people that are in this party. Navi is very busy in attending his guests. He has no time to check if there is any non-invited guest or not. You are required to help him.

All the people with having their age more than 20 are surely his invited guests. For every one of them you can determine either the age or the name of the person. You can check any person, i.e. learn his/her age or his/her name at the same time. What minimal number of people you should check additionally to make sure that there are no non-invited guests.

Input

  • First line of the input will contain two space separated integers denoting N (No. of names of some invited guests) and Q (Total number of persons present in the party).
  • Next N lines will contain strings denoting the names of the persons(one name per line and can be repetitive).
  • Next Q lines will contain either an integer denoting the age or a string denoting the name of a person.

Output

  • Output the minimal number of people you should check as asked above.

Constraints

  • 1 ≤ N ≤ 103
  • 1Q ≤ 105
  • 1 ≤ Age ≤ 50
  • 1 ≤ |Name| ≤ 50
  • Here | | denotes a length of the string and characters in this string ∈ {a, b, c ..., z}.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

You are required to check the persons with having age = 19 and name = Vipul

Editor Image

?