#include <iostream>

using namespace std;

int main() {
    string a,b;
    int sum =0;
    cin>>a>>b;
    for(int i=0;i<3;i++){
        if(a[i] == b[i]){
            sum++;
        }
    }
    cout<<sum;
}