Sarah has decided to host her birthday party at a bowling alley and and invited her friends.
Her friends will need to rent proper shoes in order to bowl, so she has sent the shoe sizes of all
of her friends to the bowling alley in advance. The bowling alley might not have enough shoes to
meet her requirements, but as long as the pair they give each person is within one size of their
desired shoe size, they will be happy.
Can you help Sarah figure out what is the maximum number of friends that the bowling alley can rent shoes to? She does not want her friends to be left shoeless!
Input
Each test case begins with an integer
and
, the
number of friends Sarah has and the number of shoe sizes that exist. The next line
contains
integers, with the
one representing how many shoes of size
the
bowling alley has. The final line contains
integers, the shoe sizes of all her friends.
Output
For each test case, output the maximum number of shoes that the bowling alley can rent out to Sarah's friends.
Sample Input
3 3
1 1 1
2 2 2
Sample Output
3
Sample Input
4 4
1 1 1 1
1 2 1 2
Sample Output
3
Explanation for Sample Input
In the first case, all of Sarah's friends are a size , while the bowling alley has a pair of
size
,
, and
. Any of these shoes will satisfy a person who is a size
, so they can
rent out all three pairs.
In the second case, the bowling alley can't rent out their size shoe to anyone, so they
can only rent out three of their shoes.
Comments