#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, x, y, m = 0;
  cin >> a >> b;
  int a1[100005], b1[100005];
  int s = 0;
  for (int i = 0; i < a; i++) {
    cin >> x;
    s = s + x;
    a1[i] = s;
  }
  s = 0;
  for (int i = 0; i < b; i++) {
    cin >> y;
    s = s + y;
    b1[i] = s;
  }
  for (int i = 0, j = 0; i < a; i++) {
  A:
    if (a1[i] == b1[j]) {
      m++;
    } else if (a1[i] > b1[j]) {
      j++;
      goto A;
    } else if (a1[i] < b1[j]) {
      i++;
      goto A;
    }
  }
  cout << m << endl;
  return 0;
}
