#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  queue<int> x, y;
  for (int i = 0; i < n; ++i) {
    int tmp;
    scanf("%d", &tmp);
    x.push(tmp);
  }
  for (int i = 0; i < m; ++i) {
    int tmp;
    scanf("%d", &tmp);
    y.push(tmp);
  }
  int ans = 0, xSum = x.front(), ySum = y.front();
  x.pop(), y.pop();
  while (!x.empty() && !y.empty()) {
    if (xSum == ySum) {
      ++ans;
      xSum = x.front();
      x.pop();
      ySum = y.front();
      y.pop();
    } else {
      if (xSum < ySum) {
        xSum += x.front();
        x.pop();
      } else {
        ySum += y.front();
        y.pop();
      }
    }
  }
  cout << ans + 1 << endl;
  return 0;
}
