#include <iostream>
#include <cstring>
using namespace std;
#define Max 256
void BNDM( const char* p,const char* t )
{
const int lengthT = strlen( t );
const int lengthP = strlen( p );
unsigned int B[Max] = { 0 };
int pos = 0;
for( int i = 0; i < lengthP; ++i )
B[p[i]] |= 1 << ( lengthP - i - 1 );
while( pos <= lengthT - lengthP )
{
int j = lengthP - 1;
int last = lengthP;
unsigned int D = -1;
while( D )
{
D = D & B[t[pos + j]];
j -= 1;
if( ( D & ( 1 << ( lengthP - 1 ) ) ) != 0 )
{
if( j > 0 )
last = j;
else
cout << pos << endl;
}
D = D << 1;
}
pos += last;
}
}
int main()
{
char p[] = "annuonce";
char t[] = "CMP_annual_conference_annuonce_ASA_annuonce";
BNDM( p, t );
return 0;
}