#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
cout.precision(17);
ios_base::sync_with_stdio(false);
int n,m;
cin>>n>>m;
ll a[200000],b[200000];
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<m;i++){
cin>>b[i];
}
ll prefi=0;
ll prefj=0;
int j1=0;
int j2=0;
ll ans=0;
for(int i=0;i<n+m;){
if(prefi==prefj){
ans++;
prefi+=a[j1];
prefj+=b[j2];
j1++;
j2++;
i+=2;
}
if(prefi<prefj){
prefi+=a[j1];
j1++;
i++;
}
if(prefi>prefj){
prefj+=b[j2];
j2++;
i++;
}
}
cout<<ans;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnR5cGVkZWYgbG9uZyBsb25nIGxsOwoKaW50IG1haW4oKSB7CiAgICBjb3V0LnByZWNpc2lvbigxNyk7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGludCBuLG07CiAgICBjaW4+Pm4+Pm07CiAgICBsbCBhWzIwMDAwMF0sYlsyMDAwMDBdOwogICAgZm9yKGludCBpPTA7aTxuO2krKyl7CiAgICAgICAgY2luPj5hW2ldOwogICAgfQogICAgZm9yKGludCBpPTA7aTxtO2krKyl7CiAgICAgICAgY2luPj5iW2ldOwogICAgfQogICAgbGwgcHJlZmk9MDsKICAgIGxsIHByZWZqPTA7CiAgICBpbnQgajE9MDsKICAgIGludCBqMj0wOwogICAgbGwgYW5zPTA7CiAgICBmb3IoaW50IGk9MDtpPG4rbTspewogICAgICAgIGlmKHByZWZpPT1wcmVmail7CiAgICAgICAgICAgIGFucysrOwogICAgICAgICAgICBwcmVmaSs9YVtqMV07CiAgICAgICAgICAgIHByZWZqKz1iW2oyXTsKICAgICAgICAgICAgajErKzsKICAgICAgICAgICAgajIrKzsKICAgICAgICAgICAgaSs9MjsKICAgICAgICB9CiAgICAgICAgaWYocHJlZmk8cHJlZmopewogICAgICAgICAgICBwcmVmaSs9YVtqMV07CiAgICAgICAgICAgIGoxKys7CiAgICAgICAgICAgIGkrKzsKICAgICAgICB9CiAgICAgICAgaWYocHJlZmk+cHJlZmopewogICAgICAgICAgICBwcmVmais9YltqMl07CiAgICAgICAgICAgIGoyKys7CiAgICAgICAgICAgIGkrKzsKICAgICAgICB9CiAgICB9CiAgICBjb3V0PDxhbnM7CiAgICByZXR1cm4gMDsKfQo=