#include<bits/stdc++.h>
#define debug cout<<"\n"<<"debug"<<"\n";
#define int long long
#define il inline
using namespace std;
const int N=1;
char truex[4][4],guessx[4][4];
int a[27],b[27];
int yellow,green;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
for(int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
cin>>truex[i][j];
a[truex[i][j]-'0'-16]++;
}
}
for(int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
cin>>guessx[i][j];
b[guessx[i][j]-'0'-16]++;
}
}
for(int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
if(truex[i][j]==guessx[i][j]){
green++;
a[guessx[i][j]-'0'-16]--;
b[guessx[i][j]-'0'-16]--;
}
}
}
for(int i=1;i<=26;i++){
if(a[i]!=0&&b[i]!=0){
yellow+=a[i];
}
}
cout<<green<<"\n"<<yellow;
return 0;
}
/*
COW SAY MOO WIN THE IOI
AAA BBB CCC AYY AAA ZZZ
*/
老是91(叹气
要命啊