#include <bits/stdc++.h>
using namespace std;
int n, m;
long long dp[100005];
map<long long, int> mp;
int main() {
  int d;
  dp[0] = 0;
  mp.clear();
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d);
    dp[i] = dp[i - 1] + d;
    mp[dp[i]] = 1;
  }
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &d);
    dp[i] = dp[i - 1] + d;
    if (mp[dp[i]]) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
