Neko Finds Grapes

TimeLimit:2000MS  MemoryLimit:256MB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description

On a random day, Neko found n treasure chests and m keys. The i-th chest has an integer a_i written on it and the j-th key has an integer b_j on it. Neko knows those chests contain the powerful mysterious green Grapes, thus Neko wants to open as many treasure chests as possible.

The j-th key can be used to unlock the i-th chest if and only if the sum of the key number and the chest number is an odd number. Formally, a_i + b_j \equiv 1 \pmod{2}. One key can be used to open at most one chest, and one chest can be opened at most once.

Find the maximum number of chests Neko can open.

Input

The first line contains integers n and m (1 ≤ n, m ≤ 10^5) — the number of chests and the number of keys.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9) — the numbers written on the treasure chests.

The third line contains m integers b_1, b_2, ..., b_m (1 ≤ b_i ≤ 10^9) — the numbers written on the keys.

Output

Print the maximum number of chests you can open.

SampleInput 1
5 4
9 14 6 2 11
8 4 7 20
SampleOutput 1
3
SampleInput 2
5 1
2 4 6 8 10
5
SampleOutput 2
1
SampleInput 3
1 4
10
20 30 40 50
SampleOutput 3
0
Note

In the first example, one possible way to unlock 3 chests is as follows:

  • Use first key to unlock the fifth chest,
  • Use third key to unlock the second chest,
  • Use fourth key to unlock the first chest.

In the second example, you can use the only key to unlock any single chest (note that one key can't be used twice).

In the third example, no key can unlock the given chest.

Submit
题目统计信息详细
总AC数27
通过人数26
尝试人数27
总提交量30
AC率86.67%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: