P26744 [AtCoder] Boxes and Keys
提高
题目描述

Problem Description

Bitaro the Beaver has obtained $ N $ locked treasure chests and $ M $ keys. The $ N $ chests are numbered from $ 1 $ to $ N $, and chest $ i $ ($1 \leq i \leq N$) has an integer $ A_i $ written on it. The $ M $ keys are numbered from $ 1 $ to $ M $, and key $ j $ ($1 \leq j \leq M$) has an integer $ B_j $ written on it.

Chest $ i $ can be unlocked using the key with the integer $ A_i $ written on it. The same key can be used to unlock multiple chests.

Bitaro wants to unlock as many chests as possible. Determine the maximum number of chests Bitaro can unlock.

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $ $ A_1 $ $ A_2 $ $\cdots$ $ A_N $ $ B_1 $ $ B_2 $ $\cdots$ $ B_M $

Output Format

Output the maximum number of chests Bitaro can unlock.

Sample Input and Output

Sample Input #1

4 4
2 2 3 1
2 1 4 1

Sample Output #1

3

Sample Input #2

5 3
1 1 1 1 1
1 1 1

Sample Output #2

5

Sample Input #3

10 11
7 447 71 130 24 1 2 221 71 1334
14 93 2000 204 447 221 7 101 7 1 30

Sample Output #3

4

Notes/Hints

Constraints

  • $1 \leq N \leq 100$.
  • $1 \leq M \leq 100$.
  • $1 \leq A_i \leq 2,000$ ($1 \leq i \leq N$).
  • $1 \leq B_j \leq 2,000$ ($1 \leq j \leq M$).
  • All input values are integers.

Sample Explanation 1

  • Chest $ 1 $ has the integer $ 2 $ written on it. Key $ 1 $ also has the integer $ 2 $ written on it. Therefore, chest $ 1 $ can be unlocked using key $ 1 $.
  • Chest $ 2 $ can be unlocked using key $ 1 $.
  • Chest $ 3 $ cannot be unlocked using any key.
  • Chest $ 4 $ can be unlocked using key $ 2 $ or key $ 4 $.

Therefore, Bitaro can unlock a maximum of $ 3 $ chests.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 4 2 2 3 1 2 1 4 1
样例输出
3