#include<bits/stdc++.h>
#define int long long
using namespace std;
int i, j, k, la, lb, kmp[1000005];
char a[1000005], b[1000005];
signed main(){
scanf("%s%s", a+1, b+1);//a为文本串, b为模式串
la = strlen(a+1), lb = strlen(b+1);
//b[1]匹配自己为0
for(i=2; i<=lb; i=-~i){//自己匹配自己
while(j&&b[j+1]!=b[i]) j=kmp[j];//j为当前到的最长长度(最长子串结尾下标)
//此while是用于判断匹配不成功的情况(直到成功为止)
if(b[j+1]==b[i]) j++;
kmp[i] = j;
}
for(i=1, j=0; i<=la; i=-~i){
while(j&&b[j+1]!=a[i]) j=kmp[j];
if(b[j+1]==a[i]) j++;
if(j==lb){//匹配完一个
printf("%d\n", i-lb+1);//输出开头
j=kmp[j];
}
}
for(i=1; i<=lb; i=-~i){
printf("%d ", kmp[i]);
}
return 0;
}