#include <iostream>
#include<cstring>
using namespace std;

int BF(string S,string T)
{
    int i=0;
    int j=0;
    while(S[i]!='\0' && T[i]!='\0')
    {
        if(S[i]==T[j])
        {
            i++;
            j++;
        }
        else
        {
            i=i-j+1;
            j=0;
        }

    }
    if(T[i]=='\0')
        return (i-j+1);
    else
        return 0;
}
int main()
{
    string S,T;
    cout<<"cin:S"<<endl;
    cin>>S;
    cout<<"cin:T"<<endl;
    cin>>T;
    cout<<BF(S,T)<<endl;
    return 0;
}