#include <bits/stdc++.h>
template <typename _T>
using MaxHeap = std::priority_queue<_T>;
template <typename _T>
using MinHeap = std::priority_queue<_T, std::vector<_T>, std::greater<_T>>;
template <typename _T>
inline bool chmax(_T &_l, const _T _b) {
  if (_l < _b) {
    _l = _b;
    return true;
  }
  return false;
}
template <typename _T>
inline bool chmin(_T &_l, const _T _b) {
  if (_l > _b) {
    _l = _b;
    return true;
  }
  return false;
}
template <typename _T>
void vdeb(const std::vector<_T> &bb) {
  for (unsigned int i = 0; i < bb.size(); i++) {
    if (i == bb.size() - 1)
      std::cout << bb[i];
    else
      std::cout << bb[i] << ' ';
  }
  std::cout << '\n';
}
template <typename _T>
void vdeb(const std::vector<std::vector<_T>> &bb) {
  for (unsigned int i = 0; i < bb.size(); i++) {
    std::cout << i << ' ';
    vdeb(bb[i]);
  }
  std::cout << '\n';
}
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, m, p;
  cin >> n >> m >> p;
  vector<int> a(n);
  for (int i = (0); i < (int)(n); i++) cin >> a[i];
  vector<int> b(m);
  for (int i = (0); i < (int)(m); i++) cin >> b[i];
  vector<vector<int>> da(p, vector<int>(0));
  for (int i = (0); i < (int)(n); i++) {
    da[i % p].push_back(a[i]);
  }
  unordered_map<int, int> mp;
  for (int i = (0); i < (int)(m); i++) {
    mp[b[i]] += 1;
  }
  vector<int> ans;
  for (int i = (0); i < (int)(p); i++) {
    int now = m;
    unordered_map<int, int> cnt;
    for (int j = (0); j < (int)(da[i].size()); j++) {
      now -= abs(cnt[da[i][j]] - mp[da[i][j]]);
      cnt[da[i][j]] += 1;
      now += abs(cnt[da[i][j]] - mp[da[i][j]]);
      if (m <= j) {
        now -= abs(cnt[da[i][j - m]] - mp[da[i][j - m]]);
        cnt[da[i][j - m]] -= 1;
        now += abs(cnt[da[i][j - m]] - mp[da[i][j - m]]);
      }
      if (now == 0) {
        ans.push_back(p * (j - m + 1) + i + 1);
      }
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << endl;
  vdeb(ans);
}
