#include <bits/stdc++.h>
using namespace std;
long long ans[100010], res[100010];
int main() {
  long long n, m;
  scanf("%lld%lld", &n, &m);
  for (int i = 0; i < n; i++) scanf("%lld", &ans[i]);
  for (int j = 0; j < m; j++) scanf("%lld", &res[j]);
  int p = 1, q = 1;
  long long a = ans[0];
  long long b = res[0];
  int result = 0;
  while (p <= n && q <= m) {
    if (a == b) {
      result++;
      if (p <= n - 1)
        a += ans[p++];
      else if (q <= m - 1)
        b += res[q++];
      else {
        break;
      }
    } else if (a < b) {
      a += ans[p++];
    } else {
      b += res[q++];
    }
  }
  if (p != n || q != m)
    printf("%d\n", result + 1);
  else
    printf("%d\n", result);
  return 0;
}
