#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a[100010], b[100010];
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) cin >> b[i];
  int r = 1, l = 1, ans = 0;
  while (r <= n && l <= m) {
    long long c = a[r++], d = b[l++];
    while (c != d) {
      while (c < d && r <= n) c += a[r++];
      while (c > d && l <= m) d += b[l++];
      if (r > n || l > m) break;
    }
    ans++;
  }
  cout << ans << endl;
}
