#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005];
int main() {
  int x, y, ans = 0, sum = 0;
  scanf("%d%d", &x, &y);
  for (int i = 0; i < x; i++) scanf("%d", &a[i]);
  for (int i = 0; i < y; i++) scanf("%d", &b[i]), sum += b[i];
  if (sum == a[0] || sum == b[0]) return !printf("1\n");
  x = a[0];
  y = b[0];
  int p1 = 0, p2 = 0;
  while (x < sum && y < sum) {
    if (x == y) ans++;
    if (x < y)
      x += a[++p1];
    else
      y += b[++p2];
  }
  return !printf("%d\n", ans + 1);
}
