//#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
bool isSub(string a, string b)
{
int i = 0, j = 0;
while (i < a.size() && j < b.size())
{
if (a[i] == b[j])
{
j++;
}
i++;
}
return j == b.size();
}
int main()
{
string a = "sgdhhio";
string b = "sdio";
if (isSub)
{
cout << "YES" << endl;
}
else
{
cout << "NO" << endl;
}
return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
string S;
string T;
cin >> S;
cin.ignore();
cin >> T;
int cnt=0;
int j=0;
for(int i=0;i<S.size()&& j<T.size();i++)
{
if(S[i]==T[j])
{
j++;
cnt++;
}
}
cout << cnt <<endl;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main()
{
string S;
string T;
cin >> S;
cin.ignore();
cin >> T;
int cnt=0;
int i=0;
int j=0;
while (i<S.size()&& j<T.size())
{
if(S[i]==T[j])
{
j++;
cnt++;
}
i++;
}
cout << cnt <<endl;
return 0;
}