#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  unordered_set<int> vis;
  for (int i = 0, sum = 0, a; i < n; ++i) {
    cin >> a;
    sum += a;
    vis.insert(sum);
  }
  for (int i = 0, sum = 0, a; i < m; ++i) {
    cin >> a;
    sum += a;
    ans += vis.count(sum);
  }
  cout << ans;
  return 0;
}
