1 #include<iostream> 2 #include<algorithm> 3 #include<cstring> 4 #include<cstdio> 5 using namespace std; 6 int f[1000],i,ans; 7 char s[1000],a[1000]; 8 void ppx(string a){ 9 memset(f,0,sizeof(f)); 10 for(i=1;i<a.size();i++){ 11 int j=f[i]; 12 while(j&&s[i]!=s[j]){ 13 j=f[j]; 14 } 15 if(s[i]==s[j]) 16 f[i+1]=j+1; 17 else 18 f[i+1]=0; 19 } 20 } 21 void find(string s,string a){ 22 ppx(a); 23 int j=0; 24 for(i=0;i<s.size();i++){ 25 while(j&&s[i]!=a[j]) 26 j=f[j]; 27 if(s[i]==a[j]) 28 j++; 29 if(j==a.size()){ 30 ans++; 31 } 32 } 33 } 34 int main(){ 35 int n,m; 36 while(cin>>s){ 37 ans=0; 38 cin>>a; 39 find(s,a); 40 cout<<ans<<endl; 41 } 42 return 0; 43 }