#include <bits/stdc++.h>
int s1[100005], s2[100005];
int main(void) {
  int n, m, i, x, j, ans;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    s1[i] = s1[i - 1] + x;
  }
  for (i = 1; i <= m; i++) {
    scanf("%d", &x);
    s2[i] = s2[i - 1] + x;
  }
  ans = 0;
  for (i = 1, j = 0; i <= n; i++) {
    while (s2[j] < s1[i]) j++;
    if (s2[j] == s1[i]) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
