#include <bits/stdc++.h>
using namespace std;
unordered_map<int, bool> s;
unordered_set<int> strt;
int main() {
  int n, k;
  cin >> k >> n;
  int jury[k + 1], t = 0, tc, mem;
  for (int i = 0; i < k; i++) {
    cin >> jury[i];
    if (jury[i] == 0) t++;
  }
  jury[k] = 1;
  for (int j = 0; j < n; j++) {
    cin >> mem;
    s[mem] = false;
  }
  s.erase(s.find(mem));
  if (t == k) {
    if (s.size() == 0)
      cout << 1;
    else
      cout << 0;
    return 0;
  }
  int temp = mem, ans = 0, num = 0;
  for (int j = 1; j <= k; j++) {
    num = 0;
    if (jury[j] == 0) continue;
    int curr = temp;
    for (auto it = s.begin(); it != s.end(); it++) it->second = false;
    for (int i = j - 1; i > 0; i--) {
      if (jury[i] == 0) continue;
      curr = curr - jury[i];
      if (s.find(curr) != s.end())
        if (s[curr] == false) {
          s[curr] = true;
          num++;
        }
    }
    tc = (curr - jury[0]);
    curr = temp;
    for (int i = j; i < k; i++) {
      if (jury[i] == 0) continue;
      curr = curr + jury[i];
      if (s.find(curr) != s.end())
        if (s[curr] == false) {
          s[curr] = true;
          num++;
        }
    }
    if (num == n - 1) {
      if (strt.find(tc) != strt.end()) continue;
      ans++;
      strt.insert(tc);
    }
  }
  cout << ans;
}
