//https://www.luogu.com.cn/problem/P3375
#include <iostream>
#include <cstdio>
using namespace std;
int nxt[1000005];
void getnxt(string s) {
int n = s.length();
for (int i = 1, j = 0; i < n; i++) {
while (j && s[i] != s[j]) j = nxt[j];
if (s[i] == s[j]) nxt[i + 1] = ++j; else nxt[i + 1] = 0;
}
}
void match(string s, string t) {
int n = s.length(), Tlen = t.length();
for (int i = 0, j = 0; i < n; i++) {
while (j && s[i] != t[j]) j = nxt[j];
if (s[i] == t[j]) j++;
if (j == Tlen) printf("%d\n", i - Tlen + 2);
}
}
int main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
string s, t;
cin >> s >> t;
getnxt(t), match(s, t);
for (int i = 1, Tlen = t.length(); i <= Tlen; i++) printf("%d ", nxt[i]);
return 0;
}