#include <iostream>
#include <algorithm>
using namespace std;
#define lson (mid << 1)
#define rson (mid << 1 | 1)
typedef long long ll;
const int maxn = 1e6 + 10;
const int B = 13331;
const int P = 1222827239;
int n, m, A, S, tot, a[maxn], b[maxn], p[maxn], res[maxn], c[maxn << 1], sz[maxn << 1];
void update(int k, int l, int r, int p, int v, bool T) {
if (l == r) { c[k] = v; sz[k] = T; return; }
int mid = (l + r) >> 1;
if (p <= mid) update(lson, l, mid, p, v, T);
else update(rson, mid + 1, r, p, v, T);
sz[k] = sz[lson] + sz[rson];
c[k] = (c[lson] + (ll)b[sz[lson]] * c[rson]) % P;
}
int main() {
ios::sync_with_stdio(false);
cin >> n >> m; b[0] = 1;
for (int i = 1, x; i <= n; i++)
cin >> x, b[i] = (ll)b[i - 1] * B % P,
S = (S + b[i - 1]) % P, A = (A + (ll)x * b[i - 1]) % P;
for (int i = 1; i <= m; i++) cin >> a[i], p[i] = a[i];
sort(p + 1, p + m + 1);
for (int i = 1; i <= m; i++) {
a[i] = lower_bound(p + 1, p + m + 1, a[i]) - p;
update(1, 1, m, a[i], i, 1);
if (i < n) continue;
if (((c[1] - (ll)S * (i - n)) % P + P) % P == A) res[++tot] = i - n + 1;
update(1, 1, m, a[i - n + 1], 0, 0);
} cout << tot << '\n';
for (int i = 1; i <= tot; i++) cout << res[i] << ' ';
return 0;
}