using namespace std;
char a[1008600],b[1008600];
int l=0,r=0,anext[1008600];
void snext(string b) {
int len = b.size();
anext[0] = 0;
for (int i = 1; i < len; i++) {
if (b[i] != b[anext[i-1]]) {
if (b[i] == b[0])
anext[i]++;
} else
anext[i] = anext[i - 1] + 1;
}
}
int main() {
cin>>a;
cin>>b;
int lena = strlen(a);
int lenb = strlen(b);
snext(b);
//cout<<l<<' '<<r;
while(l<lena){
if(a[l]==b[r]){
l++;
r++;
}
else
if(r==0){
l++;
}
else {
r=anext[r-1];
}
if(r==lenb)cout<<l-r+1<<endl;
}
for(int i=0;i<lenb;i++)cout<<anext[i]<<' ';
return 0;
}