#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, a, counter = 0;
  vector<int> x, y;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> a;
    x.push_back(a);
  }
  for (i = 0; i < m; i++) {
    cin >> a;
    y.push_back(a);
  }
  int first = 0, second = 0;
  a = x[first];
  int b = y[second];
  while (first < n && second < m) {
    if (a == b) {
      first++;
      second++;
      a = x[first];
      b = y[second];
      counter++;
    } else if (a < b) {
      first++;
      a += x[first];
    } else {
      second++;
      b += y[second];
    }
  }
  cout << counter << endl;
}
