#include <bits/stdc++.h>
using namespace std;
const int mx = 40005;
int a[mx], f[mx], b[mx];
set<int> st, ans;
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    f[0] = a[0];
    st.clear();
    for (int i = 1; i < n; i++) f[i] = f[i - 1] + a[i];
    for (int i = 0; i < n; i++) st.insert(f[i]);
    for (int i = 0; i < m; i++) scanf("%d", &b[i]);
    sort(b, b + m);
    ans.clear();
    for (int i = 0; i < n; i++) {
      int sum = b[0] - f[i];
      int ok = 1;
      for (int j = 1; j < m; j++) {
        int s = b[j] - sum;
        if (st.find(s) == st.end()) {
          ok = 0;
          break;
        }
      }
      if (ok) ans.insert(sum);
    }
    printf("%d\n", ans.size());
  }
  return 0;
}
