#include <bits/stdc++.h>
int main() {
  long n, m;
  std::cin >> n >> m;
  long *x = new long[n];
  long *y = new long[m];
  int a = 0;
  while (a < n) {
    std::cin >> x[a];
    a++;
  }
  a = 0;
  while (a < m) {
    std::cin >> y[a];
    a++;
  }
  unsigned long sum_x, sum_y;
  long k = 0;
  long l = 0;
  long counter = 0;
  sum_x = x[0];
  sum_y = y[0];
  while (k < n && l < m) {
    if (sum_x > sum_y) {
      l++;
      sum_y += y[l];
    } else if (sum_y > sum_x) {
      k++;
      sum_x += x[k];
    } else if (sum_y == sum_x) {
      counter++;
      l++;
      k++;
      sum_y += y[l];
      sum_x += x[k];
    }
  }
  std::cout << counter;
  delete (x);
  delete (y);
  x = nullptr;
  y = nullptr;
}
