#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
string s1,s2;
int s=0;
int main()
{
	cin>>s1>>s2;
	for(int i=0;i<3;i++)
	{
		if(s1[i]==s2[i])
		s++;
	}
	cout<<s;
}
