#include <bits/stdc++.h>
using namespace std;
int n,m,xy[2][2]={{0,1},{1,0}},res;
long long b[310][2],a[310][310],mk[310][310];
struct node {
int x,y;
};
void bfs (int x,int y) {
queue<node>q;
q.push((node){x,y});
while (q.size()) {
node t=q.front();
q.pop();
for (int i=0;i<2;i++) {
int xx=t.x+xy[i][0];
int yy=t.y+xy[i][1];
if (xx>0&&xx<=n&&yy>0&&yy<=m&&a[xx][yy]>=0&&mk[xx][yy]==0) {
mk[xx][yy]=1;
if (yy==m) res++;
q.push((node){xx,yy});
}
}
}
}
int main () {
freopen("expansion.in","r",stdin);
freopen("expansion.out","w",stdout);
cin >> n >> m;
for (int i=1;i<=n;i++) cin >> b[i][0];
for (int i=1;i<=m;i++) cin >> b[i][1];
for (int i=1;i<=n;i++) {
for (int j=1;j<=m;j++) {
a[i][j]=b[i][0]+b[j][1];
}
}
for (int i=1;i<=n;i++) {
if (a[i][1]<0) continue;
bfs(i,1);
memset(mk,0,sizeof(mk));
}
cout << res <<endl;
return 0;
}