#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int x[maxn], y[maxn];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) scanf("%d", &x[i]);
  for (int i = 0; i < m; i++) scanf("%d", &y[i]);
  int sumx = 0, sumy = 0, j = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    sumx += x[i];
    while (sumy + y[j] <= sumx) sumy += y[j], j++;
    if (sumx == sumy) ans++;
  }
  cout << ans << endl;
  return 0;
}
