#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int a[maxn], b[maxn];
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    for (int i = 0; i < n; i++) scanf("%d", a + i);
    int x, l = 0, p = 0, q = a[0];
    for (int i = 0; i < m; i++) {
      scanf("%d", &x);
      q -= x;
      while (q < 0) q += a[++l];
      if (q == 0) p++;
    }
    printf("%d\n", p);
  }
  return 0;
}
