1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4
5 using namespace std;
6
7 int m,n;
8 char s[1010];
9 char t[1010];
10 int next1[1010];
11
12 void getnext()
13 {
14 next1[0]=-1;
15 int i=0;
16 int j=-1;
17 while(i<m)
18 {
19 while(j!=-1&&t[i]!=t[j])
20 {
21 j=next1[j];
22 }
23 next1[++i]=++j;
24 }
25 }
26
27 int kmp()
28 {
29 int ans=0;
30 int i=0;
31 int j=0;
32 getnext();
33 while(i<n)
34 {
35 while(j!=-1&&s[i]!=t[j])
36 {
37 j=next1[j];
38 }
39 i++;
40 j++;
41 if(j>=m)
42 {
43 ans++;
44 j=0;
45 }
46 }
47 return ans;
48 }
49
50 int main()
51 {
52 while(scanf("%s",&s)!=EOF)
53 {
54 if(s[0]=='#')
55 break;
56 scanf("%s",&t);
57 n=strlen(s);
58 m=strlen(t);
59 cout<<kmp()<<endl;
60 }
61 return 0;
62 }