#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n,m;
    cin>>n>>m;
    int a[n],b[m];
    int br0 = 0;
    int br1 = 1;
    for(int i =0;i<n;i++){
        cin>>a[i];
        if(a[i]==0)br0++;
        else if(a[i]==1)br1++;
    }
    for(int i =0;i<n;i++){
        cin>>b[i];
        if(b[i]==0)br0++;
        else if(b[i]==1)br1++;
    }
    if(br1>br0)cout<<br0;
    else cout<<br1;
}