#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::make_pair;
using std::pair;
using std::string;
using std::vector;
using pii = pair<int, int>;
int s[2003], tmp[2003];
std::map<int, int> h;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int a;
    scanf("%d", &a);
    s[i] = s[i - 1] + a;
  }
  vector<int> dap;
  for (int i = 0; i < m; i++) {
    int a;
    scanf("%d", &a);
    vector<int> vec;
    for (int j = 1; j <= n; j++) {
      vec.push_back(a - s[j]);
    }
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    if (i == 0)
      dap = vec;
    else {
      int l = 0, r = 0, cnt = 0;
      while (l < vec.size() && r < dap.size()) {
        if (vec[l] == dap[r])
          tmp[cnt++] = vec[l++];
        else if (vec[l] > dap[r])
          r++;
        else
          l++;
      }
      dap.clear();
      for (int i = 0; i < cnt; i++) dap.push_back(tmp[i]);
    }
  }
  printf("%d", dap.size());
}
