#K72977. Count Matching Transactions

    ID: 33873 Type: Default 1000ms 256MiB

Count Matching Transactions

Count Matching Transactions

You are given a list of transactions where each transaction is represented by a string indicating its category. Additionally, you are given a list of specific categories. Your task is to count the number of transactions that belong to at least one of the specific categories.

Formally, given a list \( T = [t_1, t_2, \ldots, t_n] \) of transactions and a set \( S \) of specific categories, you need to compute the number \( c \) defined by:

[ c = \sum_{i=1}^{n} \mathbf{1}_{{t_i \in S}}, ]

where \( \mathbf{1} \) is the indicator function.

The input is read from standard input and the output must be printed to standard output.

inputFormat

The input is given in the following format:

n
transaction_1
transaction_2
... 
transaction_n
m
category_1
category_2
...
category_m

Here, n is the number of transactions, followed by n lines each containing a transaction category. Then an integer m is provided, followed by m lines each with a specific category.

outputFormat

Output a single integer indicating the number of transactions that match at least one of the specific categories.

## sample
10
food
electronics
clothing
grocery
healthcare
automotive
food
healthcare
travel
electronics
3
food
electronics
travel
5