#include <bits/stdc++.h>
using namespace std;
const int maxn = 8e6 + 5;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
int z[maxn], f[maxn];
int n, k, a[2005], b[2005], sum[2005];
int main() {
  scanf("%d%d", &k, &n);
  for (int i = 1; i <= k; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  set<int> s;
  sum[1] = a[1];
  s.insert(sum[1]);
  for (int i = 2; i <= k; i++) {
    sum[i] = sum[i - 1] + a[i];
    s.insert(sum[i]);
  }
  int ind = 1;
  for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
    sum[ind++] = *it;
  }
  k = s.size();
  for (int i = 1; i <= n; i++) {
    int t = b[i];
    for (int j = 1; j <= k; j++) {
      int tmp = t - sum[j];
      if (tmp >= 0)
        z[tmp]++;
      else
        f[(-tmp)]++;
    }
  }
  int ans = 0;
  for (int i = 0; i < maxn; i++) {
    if (z[i] == n) ans++;
    if (f[i] == n) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
