byd_xyz001 @ 2024-12-01 21:31:21
#include <bits/stdc++.h>
using namespace std;
long long n,m,x,a[500005],b[500005],ans;
bool check(long long k)
{
b[0]=-1e9,b[m+1]=1e9;
long long l = 1,r = m,mid;
while(l+1< r)
{
mid = (l + r) / 2;
if (k < b[mid])
{
r = mid;
}
else if(k > b[mid])
{
l = mid;
}
else
{
return 1;
}
}
return 0;
}
int main()
{
cin >> n >> m;
for(int i = 1;i <= n;i++)
{
cin >>a[i];
}
for(int i = 1;i <= m;i++)
{
cin >> b[i];
}
sort(b +1,b + m + 1);
if(!check(a[n]))
{
ans++;
}
for(int i = 1;i < n;i++)
{
if(!check(a[i]) && check(a[i + 1]))
{
ans++;
}
}
cout << ans;
return 0;
}