#include <bits/stdc++.h>
using namespace std;
long long l, r, ans, sum, n, n1;
vector<int> ve, ve1;
int main() {
  scanf("%lld%lld", &n, &n1);
  for (int j = 0; j < n; ++j) {
    scanf("%lld", &l);
    sum += l;
    ve.push_back(sum);
  }
  sum = 0;
  for (int j = 0; j < n1; ++j) {
    scanf("%lld", &l);
    sum += l;
    ve1.push_back(sum);
  }
  sort(ve.begin(), ve.end());
  sort(ve1.begin(), ve1.end());
  for (int j = 0; j < ve.size(); ++j) {
    int l = 0, r = ve1.size() - 1;
    while (l <= r) {
      int mid = (l + r) / 2;
      if (ve1[mid] == ve[j]) {
        ans++;
        break;
      } else if (ve1[mid] > ve[j]) {
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
  }
  printf("%lld", ans);
  return 0;
}
