#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int maxn = 8000010;
bool bcheck[maxn] = {0};
bool bcurr[maxn] = {0};
const int base = 4000005;
int main() {
  set<long long> starts;
  starts.insert(0);
  int k, n;
  cin >> k >> n;
  vector<int> a(k);
  vector<long long> am(k);
  for (int i = 0; i < k; i++) cin >> a[i];
  am[0] = a[0];
  for (int i = 1; i < k; i++) am[i] = am[i - 1] + 0LL + a[i];
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    bcheck[base + b[i]] = true;
  }
  for (int i = 0; i < k; i++) starts.insert(b[0] - am[i]);
  int minb = *min_element((b).begin(), (b).end());
  int maxb = *max_element((b).begin(), (b).end());
  int minam = *min_element((am).begin(), (am).end());
  int maxam = *max_element((am).begin(), (am).end());
  int res = 0;
  for (auto s : starts) {
    if (s + minam > minb) continue;
    if (s + maxam < maxb) continue;
    int cnt = 0;
    long long cur = s;
    int cur_found = 0;
    for (int i = 0; i < (int)(b).size(); i++) bcurr[base + b[i]] = false;
    for (int i = 0; i < k; i++) {
      if (cur_found >= n) break;
      cur += a[i];
      if (!bcurr[base + maxb] && cur + 2000 * (k - i) < maxb) break;
      if (!bcurr[base + minb] && cur - 2000 * (k - i) > minb) break;
      if (cur + base >= maxn) continue;
      if (bcheck[base + cur]) {
        if (!bcurr[base + cur]) {
          cur_found++;
          bcurr[base + cur] = true;
        }
      }
      if (i - cur_found >= k - n + 1) break;
    }
    if (cur_found >= n) res++;
  }
  cout << res;
  return 0;
}
