#include<stdio.h>
#include<iostream>
#include<string>
#include<string.h>
#include<math.h>
#include<functional>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
const int maxn = 1005;
const int inf = 1<<30;//0x7f;
typedef __int64 LL;
int ans;
int Next[maxn];
void GetNext( char *str,int *Next )
{
int len = strlen(str);
Next[0] = Next[1] = 0;
for( int i = 1; i < len; i ++ )
{
int j = Next[i];
while( j && str[i] != str[j] ) j = Next[j];
Next[i+1] = str[i] == str[j]?j+1:0;
}
}
void find( char *str,char *p,int *Next )
{
int nlen = strlen(str);
int mlen = strlen(p);
GetNext( p,Next );
int j = 0;
for( int i = 0; i < nlen; i ++ )
{
while( j && p[j] != str[i] ) j = Next[j];
if( p[j] == str[i] ) j ++;
if( j == mlen ){
printf("%d\n",i-mlen+1); //匹配开始点
//j = 0;
}
}
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("data.txt","r",stdin);
#endif
char str[maxn],p[maxn];
while( scanf("%s ",str) != EOF )
{
if( str[0] == '#' ) break;
ans = 0;
scanf("%s\n",p);
memset( Next,0,sizeof(Next));
find( str,p,Next );
}
return 0;
}