#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int x[maxn], y[maxn];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> y[i];
  }
  int u = 0, d = 0, ans = 0;
  int sumu = 0, sumd = 0;
  while (u <= n && d <= m) {
    if (sumu && sumu == sumd) {
      ans++;
      sumd = y[++d];
      sumu = x[++u];
    } else if (sumu > sumd) {
      sumd += y[++d];
    } else if (sumu <= sumd) {
      sumu += x[++u];
    }
  }
  cout << ans << endl;
  return 0;
}
