#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
map<int, int> use, dd;
int n, a[300005], b[300005], A[300005], m, cnt, p;
void Solve(int x) {
  use.clear();
  int SI = 0, num = 0;
  for (int i = x; i <= n; i += p) A[++SI] = a[i];
  if (m > SI) return;
  for (int i = 1; i <= m; i++) {
    use[A[i]]++;
    int u = dd[A[i]];
    if (u == 0) continue;
    if (use[A[i]] == u) num++;
    if (use[A[i]] == u + 1) num--;
  }
  if (num == cnt) ans.push_back(x);
  for (int i = m + 1; i <= SI; i++) {
    use[A[i - m]]--;
    int u = dd[A[i - m]];
    if (u) {
      if (use[A[i - m]] == u) num++;
      if (use[A[i - m]] == u - 1) num--;
    }
    use[A[i]]++;
    u = dd[A[i]];
    if (u) {
      if (use[A[i]] == u) num++;
      if (use[A[i]] == u + 1) num--;
    }
    if (num == cnt) ans.push_back(x + p * (i - m));
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> p;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) cin >> b[i];
  for (int i = 1; i <= m; i++) {
    if (dd[b[i]] == 0) cnt++;
    dd[b[i]]++;
  }
  for (int i = 1; i <= p; i++) Solve(i);
  cout << ans.size() << endl;
  sort(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
}
