#include <bits/stdc++.h>
using namespace std;

#define DEBUG

// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;

const int MOD = 1000000007;

// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;

// 繰り返し
#define rep(n) for(int i=0;i<(int)(n);i++)
#define rep_(n) for(int i=0;i<(int)(n-1);i++)
#define rep__(n) for(int i=n-1;i>=0;i--)

// メモリ関連
#define SZ(x) ((int)(x).size())
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define MEMSET(v,h) memset((v),h,sizeof(h)

// 最大値と最小値を更新する
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

// 要素を見つける
template<class T>T findVector(vector<T>v,int n){auto it=find(v.begin(),v.end(),n);if(distance(v.begin(),it)!=v.size())return index;return 0;}

// 素数判定
bool isPrime(int n){if(n<2)return false;else if(n==2)return true;else if(n%2==0)return false;double sqrtNum=sqrt(n);for(int i=3;i<=sqrtNum;i+=2)if(n%i==0)return false;return true;}

// 入力関係
template<class T>T scan(){T t;cin>>t;return t;}
template<class T>T*scanArray(size_t n){T*a=(T*)malloc(n*sizeof(T));rep(n)cin>>a[i];return a;}
template<class T>list<T>scanList(size_t n){list<T>l;rep(n)cin>>l[i];return l;}
template<class T>vector<T>scanVector(size_t n){vector<T>v(n);rep(n)cin>>v[i];return v;}
template<class T>set<T>scanSet(size_t n){set<T>s;T t;rep(n){cin>>t;s.insert(t);}return s;}
template<class T,class U>map<T,U>scanMap(size_t n){map<T,U>m;vector<T>v(n);rep(n)cin>>v[i];U u;rep(n){cin>>u;m[v[i]]=u;}return m;}
template<class T>stack<T>scanStack(size_t n){stack<T>s;T t;rep(n){cin>>t;s.push(t);}return s;}
template<class T>queue<T>scanQueue(size_t n){queue<T>q;T t;rep(n){cin>>t;q.push(t);}return q;}
template<class T>deque<T>scanDeque(size_t n){deque<T>d;T t;rep(n){cin>>t;d.push_back(t);}return d;}
template<class T,class U>unordered_map<T, U>scanUnorderedMap(size_t n){unordered_map<T,U>m;vector<T>v(n);rep(n)cin>>v[i];U u;rep(n){cin>>u;m[v[i]]=u;}return m;}

// デバッグ用
#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
template<class T>void printArray(T*a,size_t n){cout<<"[DEBUG] <array>"<<endl;rep(n)cout<<a[i]<<endl;}
template<class T>void printList(list<T>l){cout<<"[DEBUG] <list>"<<endl;rep(l.size())cout<<"["<<i<<"] "<<*next(l.begin(),i)<<endl;}
template<class T>void printVector(vector<T>v){cout<<"[DEBUG] <vector>"<<endl;rep(v.size())cout<<"["<<i<<"] "<<v[i]<<endl;}
template<class T>void printSet(set<T>s){cout<<"[DEBUG] <set>"<<endl;rep(s.size())cout<<"["<<i<<"] "<<*next(s.begin(),i)<<endl;}
template<class T,class U>void printMap(map<T,U>m){int k=0;cout<<"[DEBUG] <map>"<<endl;for(auto it=m.begin();it!=m.end();++it)cout<<"["<<k++<<"] "<<it->first<<","<<it->second<<endl;}
template<class T>void printStack(stack<T>s){size_t si=s.size();vector<T>v(si);cout<<"[DEBUG] <stack>"<<endl;rep(si){v[i]=s.top();s.pop();}rep__(si){cout<<"["<<si-i-1<<"] "<<v[i]<<endl;}}
template<class T>void printQueue(queue<T>q){size_t si=q.size();queue<T> t;cout<<"[DEBUG] <queue>"<<endl;rep(si){cout<<"["<<i<<"] "<<q.front()<<endl;q.pop();}}
template<class T>void printDeque(deque<T>d){size_t si=d.size();cout<<"[DEBUG] <deque>"<<endl;rep(si)cout<<d[i]<<endl;}
template<class T,class U>void printUnorderedMap(unordered_map<T,U>m){int k=0;cout<<"[DEBUG] <map>"<<endl;for(auto it=m.begin();it!=m.end();++it)cout<<"["<<k++<<"] "<<it->first<<","<<it->second<<endl;}

#else
#define eprintf(...) 42
template<class T>void printArray(T*a,size_t n){}
template<class T>void printList(list<T>l){}
template<class T>void printVector(vector<T>v){}
template<class T>void printSet(set<T>s){}
template<class T,class U>void printMap(map<T,U>m){}
template<class T>void printStack(stack<T>s){}
template<class T>void printQueue(queue<T>q){}
template<class T>void printDeque(deque<T>d){}
template<class T,class U>void printUnorderedMap(unordered_map<T,U>m){}
#endif

int main(void) {
    string s = scan<string>();
    string t = scan<string>();
    int ans = (s[0] == t[0] ? 1 : 0) + (s[1] == t[1] ? 1 : 0) + (s[2] == t[2] ? 1 : 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256