#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char pat[1000005], txt[1000005];
int now=0,k,temp;
int* buildnext(char* pat)
{
int m = strlen(pat), j = 0;
int* N = new int[m+1];
int t = -1;
N[0] = -1;
while (j < m )
{
if (t < 0 || pat[j] == pat[t])
{
++t, ++j;
N[j] = t;
}
else
t = N[t];
}
return N;
}
void match(char* pat, char* txt)
{
int* next = buildnext(pat);
int m = strlen(pat), j = 0;
int n = strlen(txt);
while (j < m && now < n)
{
if (j < 0 || pat[j] == txt[now])
++now, ++j;
else
j = next[j];
}
delete[] next;
if (now - j <= n - m && now - j + 1 != temp)
{
cout << now - j + 1 << endl;
temp = now - j + 1;
now = now - j + 2;
match(pat, txt);
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> txt >> pat;
match(pat, txt);
int *s2 = buildnext(pat);
int m = strlen(pat);
for (int i = 1; i <= m; ++i)
cout << s2[i] << " ";
}