#include <bits/stdc++.h>
using namespace std;
int x[1000005], y[1000005];
int n, m, a, ans, sum, i;
int main() {
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> a;
    sum += a;
    x[sum]++;
  }
  sum = 0;
  for (i = 0; i < m; i++) {
    cin >> a;
    sum += a;
    y[sum]++;
  }
  ans = 0;
  for (i = 1; i <= sum; i++) {
    if (x[i] == y[i] && x[i] == 1) ans++;
  }
  cout << ans << endl;
}
