public void solve() throws IOException {
    int n = nextInt();
    int w = nextInt();
    int[] heights = new int[n];
    for (int x = 0; x < n; x++) {
      heights[x] = nextInt();
    }

    int prev = -1;
    int[] pattern = new int[w - 1];
    for (int x = 0; x < w; x++) {
      int val = nextInt();
      if (x != 0) {
        pattern[x - 1] = val - prev;
      }
      prev = val;
    }

    if (w == 1) {
      System.out.println(n);
      return;
    }

    int total = 0;
    for (int x = 0; x <= n - w; x++) {
      for (int y = x + 1; y < x + w; y++) {
        if (heights[y] - heights[y - 1] != pattern[y - x - 1]) {
          break;
        }
        if (y == x + w - 1) {
          total++;
        }
      }
    }
    System.out.println(total);
  }