#include <bits/stdc++.h>
int x[1000003];
int y[1000003];
int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  for (int i = 0; i < a; i++) scanf("%d", &x[i]);
  for (int i = 0; i < b; i++) scanf("%d", &y[i]);
  int p = 1, q = 1;
  int pn = x[0], qn = y[0];
  int ans = 0;
  while (true) {
    if (a < p || b < q) break;
    if (pn > qn) {
      qn += y[q];
      q++;
    } else if (pn == qn) {
      ans++;
      pn = x[p], qn = y[q];
      p++, q++;
    } else {
      pn += x[p];
      p++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
