rt
#include<bits/stdc++.h>
#define int long long
const int maxn=4000001;
char s[maxn],s2[maxn];
using namespace std;
int la,lb,nextt[maxn];
void build_next() {
int i=1,j=0;
nextt[0]=0;
while(i<lb) {
if(s2[i]==s2[j]) {
j++;
nextt[i]=j;
i++;
} else if(j==0) {
nextt[i]=0;
i++;
} else {
j=nextt[j-1];
}
}
}
int kmp() {
int i=0,j=0;
while(i<la) {
if(s[i]==s2[j]) {
i++;
j++;
} else if(j>0) {
j=nextt[j-1];
} else i++;
if(j==lb) {
cout<<i-lb+1<<endl;
j=nextt[j-1];
}
}
}
signed main() {
cin>>s>>s2;
la=strlen(s);
lb=strlen(s2);
build_next();
kmp();
for(int i=0;i<lb;i++){
cout<<nextt[i]<<" ";
}
}
/*
ABABABC
ABA
*/