Codeforces Round #554 (Div. 2) A

On a random day, Neko found n treasure chests and m keys. The i-th chest has an integer ai written on it and the j-th key has an integer bj

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, ai+bj≡1(mod2)

. 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≤105

) — the number of chests and the number of keys.

The second line contains n

integers a1,a2,…,an (1≤ai≤109

) — the numbers written on the treasure chests.

The third line contains m

integers b1,b2,…,bm (1≤bi≤109

) — the numbers written on the keys.

Output

Print the maximum number of chests you can open.

Examples

Input

Copy

5 4
9 14 6 2 11
8 4 7 20

Output

Copy

3

Input

Copy

5 1
2 4 6 8 10
5

Output

Copy

1

Input

Copy

1 4
10
20 30 40 50

Output

Copy

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.

#include <iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
#define ll long long
int main()
{
    int n,m;
    while(scanf("%d %d",&n,&m)!=EOF)
    {
        int x1=0,y1=0,x2=0,y2=0;
        for(int i=1;i<=n;i++)
        {
            int x;
            scanf("%d",&x);
            if(x%2==1) x1++;
            else y1++;
        }
        for(int i=1;i<=m;i++)
        {
            int x;
            scanf("%d",&x);
            if(x%2==1) x2++;
            else y2++;
        }
        int m;
        m=min(x1,y2)+min(x2,y1);
        printf("%d\n",m);
    }
}

 

全部评论

相关推荐

01-14 16:23
广州商学院 Java
双非后端失败第N人:如果准备好了可以直接投字节,字节是最不看学历的,只要想面,大概率都能给你约面。
双非有机会进大厂吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务