#include<bits/stdc++.h>
#define maxn 1000010
using namespace std;
void getfail(char *p,int *f)
{
int m=strlen(p);
f[0]=0;
f[1]=0;
for(int i=1;i<m;++i)
{
int j=f[i];
while(j&&p[i]!=p[j])j=f[j];
f[i+1]=(p[i]==p[j])?j+1:0;
}
}
void find(char *t,char *p,int *f)
{
int n=strlen(t);
int m=strlen(p);
getfail(p,f);
int j=0;
for(int i=0;i<n;++i)
{
while(j&&p[j]!=t[i])j=f[j];
if(p[j]==t[i])++j;
if(j==m)printf("%d\n",i-m+2);
}
}
int f[maxn];
char p[maxn],t[maxn];
int main()
{
ios::sync_with_stdio(false);
// freopen("P3375.in","r",stdin);
// freopen("P3375.out","w",stdout);
cin>>t;
cin>>p;
find(t,p,f);
for(int i=1;i<=strlen(p);++i)
{
cout<<f[i]<<" ";
}
}