#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, temp;
  vector<int> a, b;
  int suma = 0;
  int sumb = 0;
  int la = 0, lb = 0;
  int ans = 0;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    cin >> temp;
    a.push_back(temp);
  }
  for (int j = 0; j < m; j++) {
    cin >> temp;
    b.push_back(temp);
  }
  while (la < n || lb < m) {
    if (la > n || suma > sumb)
      sumb += b[lb++];
    else
      suma += a[la++];
    if (suma == sumb) ans++;
  }
  cout << ans;
}
