#include <bits/stdc++.h>
using namespace std;
template <typename T>
T mabs(const T &a) {
  return a < 0 ? -a : a;
}
int n, m, p, bss;
vector<int> a, b;
map<int, int> bCounts;
vector<int> checkPos(int sp) {
  vector<int> res;
  map<int, int> aCounts;
  int wrongCounts = bss;
  for (int i = (0), ei = (m); i < ei; i++) {
    int cp = sp + i * p;
    if (cp >= n) return res;
    int aVal = a[cp];
    int cac = aCounts[aVal];
    int nac = cac + 1;
    if (cac == bCounts[aVal])
      wrongCounts++;
    else if (nac == bCounts[aVal])
      wrongCounts--;
    aCounts[aVal] = nac;
  }
  int moved = 0;
  while (1) {
    if (wrongCounts == 0) res.push_back(sp + moved * p);
    int curExc = a[sp + moved * p];
    int curIncIdx = sp + (moved + m) * p;
    if (curIncIdx >= n) break;
    int curInc = a[curIncIdx];
    {
      int cac = aCounts[curExc];
      int nac = cac - 1;
      if (cac == bCounts[curExc])
        wrongCounts++;
      else if (nac == bCounts[curExc])
        wrongCounts--;
    }
    if (wrongCounts < 0) throw 1;
    aCounts[curExc]--;
    {
      int cac = aCounts[curInc];
      int nac = cac + 1;
      if (cac == bCounts[curInc])
        wrongCounts++;
      else if (nac == bCounts[curInc])
        wrongCounts--;
    }
    if (wrongCounts < 0) throw 1;
    aCounts[curInc]++;
    moved++;
  }
  return res;
}
void run() {
  scanf("%d%d%d", &n, &m, &p);
  for (int i = (0), ei = (n); i < ei; i++) {
    int cur;
    scanf("%d", &cur);
    a.push_back(cur);
  }
  for (int i = (0), ei = (m); i < ei; i++) {
    int cur;
    scanf("%d", &cur);
    b.push_back(cur);
    bCounts[cur]++;
  }
  bss = bCounts.size();
  vector<int> res;
  for (int i = (0), ei = (p); i < ei; i++) {
    vector<int> cur = checkPos(i);
    for (int j = (0), ej = (cur.size()); j < ej; j++) res.push_back(cur[j]);
  }
  sort((res).begin(), (res).end());
  printf("%d\n", (int)res.size());
  for (int i = (0), ei = (res.size()); i < ei; i++) {
    printf("%d ", res[i] + 1);
  }
}
int main() {
  run();
  return 0;
}
