#include<set>
#include<list>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
    char a,b,c;
    char a1,b1,c1;
    cin>>a>>b>>c>>a1>>b1>>c1;
    int ans=0;
    if(a==a1)
        ans++;
    if(b==b1)
        ans++;
    if(c==c1)
        ans++;
    cout<<ans;
    return 0;
}