#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, z = 0, x = 0, cou = 0;
  cin >> n >> k;
  int arr1[n], arr2[k];
  for (int i = 0; i < n; i++) cin >> arr1[i];
  for (int i = 0; i < k; i++) cin >> arr2[i];
  int sum1 = arr1[z++];
  int sum2 = arr2[x++];
  while (z <= n || x <= k) {
    if (sum1 == sum2) {
      cou++;
      sum1 = arr1[z++];
      sum2 = arr2[x++];
    } else if (sum1 > sum2) {
      sum2 += arr2[x++];
    } else
      sum1 += arr1[z++];
  }
  cout << cou << endl;
  return 0;
}
