#include <bits/stdc++.h>
using namespace std;
long long int n, m, a[1000007], p, c[1000007], akt[1000007];
int ok[1000007];
vector<int> b, odp;
void dane() {
  cin >> n >> m >> p;
  for (int i = (0); i < (n); i++) cin >> a[i];
  for (int i = (0); i < (m); i++) {
    int x;
    cin >> x;
    b.push_back(x);
  }
  sort(b.begin(), b.end());
  int rozne = 0;
  int pop = b[0];
  for (int i = (0); i < (b.size()); i++) {
    if (pop != b[i]) rozne++;
    pop = b[i];
    c[rozne]++;
  }
  vector<int>::iterator it = unique(b.begin(), b.end());
  b.resize(distance(b.begin(), it));
  for (int i = (0); i < (n); i++) {
    long long int aktt = a[i];
    vector<int>::iterator it;
    it = lower_bound(b.begin(), b.end(), aktt);
    int poz = (it - b.begin());
    if (*it == aktt && it != b.end())
      aktt = poz;
    else
      aktt = 1000004;
    a[i] = aktt;
  }
  rozne++;
  long long int pocz = 0;
  while (pocz < p) {
    if (pocz + (m - 1) * p >= n) {
      pocz++;
      continue;
    }
    long long int ile = 0;
    long long int ele = 0;
    int wsio = 0;
    while (ele < m) {
      int pz = pocz + ele * p;
      akt[a[pz]]++;
      if (akt[a[pz]] == c[a[pz]])
        wsio++;
      else if (akt[a[pz]] - 1 == c[a[pz]])
        wsio--;
      ele++;
    }
    if (wsio == rozne) odp.push_back(pocz);
    long long int it = 1;
    while (pocz + (m - 1) * p + it * p < n) {
      int pz1 = pocz + (it - 1) * p;
      int pz2 = pocz + (m - 1) * p + it * p;
      akt[a[pz1]]--;
      if (akt[a[pz1]] == c[a[pz1]])
        wsio++;
      else if (akt[a[pz1]] + 1 == c[a[pz1]])
        wsio--;
      akt[a[pz2]]++;
      if (akt[a[pz2]] == c[a[pz2]])
        wsio++;
      else if (akt[a[pz2]] - 1 == c[a[pz2]])
        wsio--;
      if (wsio == rozne) odp.push_back(pocz + it * p);
      it++;
    }
    pocz++;
    for (int i = (0); i < (rozne); i++) akt[i] = 0;
  }
  sort(odp.begin(), odp.end());
  cout << odp.size() << "\n";
  for (int i = (0); i < (odp.size()); i++) printf("%d ", odp[i] + 1);
  cout << "\n";
}
int main() {
  dane();
  return 0;
}
