Problem Description

一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢?

Input

输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCII字符有多少个,布条的花纹也有多少种花样。花纹条和小饰条不会超过1000个字符长。如果遇见#字符,则不再进行工作。

Output

输出能从花纹布中剪出的最多小饰条个数,如果一块都没有,那就老老实实输出0,每个结果之间应换行。

Sample Input

abcde a3 
aaaaaa aa 
#

Sample Output


3

C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=10010;
char arr1[N*100],arr2[N];
int nt[N];
int n,m,s;
void getnt()
{
    int i=0,j=-1;
    nt[0]=-1;
    while(i<m)
    {
        if(j==-1||arr2[i]==arr2[j])
        {
            i++,j++;
            nt[i]=j;
        }
        else
            j=nt[j];
    }
}
int kmp()
{
    getnt();
    int i=0,j=0;
    s=0;
    while(i<n)
    {
        if(j==-1||arr1[i]==arr2[j])
            i++, j++;
        else
            j=nt[j];
        if(j>=m)
        {
            s++;
            j=0;
        }
    }
    return s;
}
int main()
{
    int t;
    while(cin>>arr1)
    {
         if(arr1[0]=='#')
            break;
         cin>>arr2;
         n=strlen(arr1);
         m=strlen(arr2);
         if(n<m)
            cout<<"0"<<endl;
         else
         {
             cout<<kmp()<<endl;
         }
    }
    return 0;
}