#K35587. Count Unlockable Locks
Count Unlockable Locks
Count Unlockable Locks
You are given two collections of sequences: one representing locks and one representing keys. A lock is considered unlockable if its sequence exactly matches one of the key sequences. Formally, given two sets \( L \) (locks) and \( K \) (keys), the answer is given by \( |L \cap K| \), where \( |\cdot| \) denotes the cardinality of a set.
Your task is to determine the number of unlockable locks.
inputFormat
The input is given from stdin in the following format:
- The first line contains two integers \( n \) and \( m \) separated by a space, where \( n \) is the number of lock sequences and \( m \) is the number of key sequences.
- The next \( n \) lines each contain a non-empty string representing a lock sequence.
- The following \( m \) lines each contain a non-empty string representing a key sequence.
outputFormat
Print a single integer to stdout which denotes the number of locks that can be unlocked.
## sample5 4
123
456
789
101
202
123
456
101
999
3