#include <bits/stdc++.h>
using namespace std;
int l, r, a, ll, rr, ans = 0, e[100005], f[100005], n, m;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &e[i]);
  for (int i = 1; i <= m; i++) scanf("%d", &f[i]);
  l = 1, r = 1, ll = e[1], rr = f[1];
  while (l < n || r < m) {
    if (ll < rr) {
      ++l;
      ll += e[l];
    } else if (ll > rr) {
      ++r;
      rr += f[r];
    } else {
      ++ans;
      ++l, ++r, ll = e[l], rr = f[r];
    }
  }
  printf("%d\n", ans + 1);
  return 0;
}
