#include <bits/stdc++.h>
using namespace std;
const int MAX = 8e6 + 4;
long long score[2004], cum[2004];
int recalls[MAX];
set<long long> options;
int main() {
  int k, n, adjust;
  cin >> k >> n;
  for (int i = 0; i < k; ++i) {
    cin >> score[i];
    cum[i + 1] = cum[i] + score[i];
  }
  for (int i = 0; i < n; ++i) {
    int tmp;
    cin >> tmp;
    recalls[tmp + 4000000] = 1;
    if (i == 0) adjust = tmp + 4000000;
  }
  for (int i = 1; i <= k; ++i) {
    int vis = 0;
    recalls[adjust] = i + 1;
    vis++;
    for (int j = i + 1; j <= k; ++j) {
      if (adjust + cum[j] - cum[i] >= 0 && adjust + cum[j] - cum[i] < MAX &&
          recalls[adjust + cum[j] - cum[i]] > 0 &&
          recalls[adjust + cum[j] - cum[i]] < i + 1) {
        recalls[adjust + cum[j] - cum[i]] = i + 1;
        vis++;
      }
    }
    for (int j = i - 1; j > 0; --j) {
      if (adjust - (cum[i] - cum[j]) >= 0 && adjust - (cum[i] - cum[j]) < MAX &&
          recalls[adjust - (cum[i] - cum[j])] > 0 &&
          recalls[adjust - (cum[i] - cum[j])] < i + 1) {
        recalls[adjust - (cum[i] - cum[j])] = i + 1;
        vis++;
      }
    }
    if (vis == n) options.insert(adjust - cum[i]);
  }
  cout << options.size() << endl;
  return 0;
}
