#include <bits/stdc++.h>
using namespace std;
set<long long> s;
long long n, m, x[100100], y[100100], anss;
int main() {
  long long i;
  scanf("%lld%lld", &n, &m);
  for (i = 1; i <= n; i++)
    scanf("%lld", &x[i]), x[i] += x[i - 1], s.insert(x[i]);
  for (i = 1; i <= m; i++) scanf("%lld", &y[i]), y[i] += y[i - 1];
  for (i = 1; i <= m; i++) {
    if (s.count(y[i])) anss++;
  }
  printf("%lld", anss);
  return 0;
}
