#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#define x first
#define y second
using namespace std;
int b[30];
vector<int> ans;
vector<pair<int,int>>anss;
int main()
{
char a[3][3];
for(int i = 0; i < 3; i ++)
{
for(int j = 0; j < 3; j ++)
{
cin >>a[i][j];
}
}
int cnt = 0, cntt = 0;
for(int i = 0; i < 3; i ++)
{
if(a[i][0] == a[i][1]&&a[i][2]==a[i][1])ans.push_back(a[i][0] - 'A');
if(a[0][i] == a[1][i] && a[2][i] == a[0][i])ans.push_back(a[0][i] -'A');
if(i == 0 && a[i][i] ==a[i + 1][i + 1] && a[i][i] == a[i + 2][i + 2])ans.push_back(a[i][i] -'A');
if(i == 0 && a[i][2] == a[i + 1][1] &&a[i][2]==a[2][0])ans.push_back(a[i][2] - 'A');
}
for(int i = 0; i < 3; i ++)
{
for(int j = 0; j < 3; j ++)
{
b[a[i][j] - 'A'] ++;
}
for(int k = 0; k <= 27; k ++)
{
if(b[k] == 2)
{
for(int g = 0; g <= 27; g ++)
{
if(b[g] == 1){
int a = k, b = g;
if(a > b)swap(a,b);
anss.push_back({a,b});
}
}
}
}
memset(b,0,sizeof b);
for(int j = 0; j < 3; j ++)
{
b[a[j][i] - 'A'] ++;
}
for(int k = 0; k <= 27; k ++)
{
if(b[k] == 2)
{
for(int g = 0; g <= 27; g ++)
{
if(b[g] == 1){
int a = k, b = g;
if(a > b)swap(a,b);
anss.push_back({a,b});
}
}
}
}
memset(b,0,sizeof b);
}
b[a[0][0] - 'A']++;
b[a[1][1] - 'A']++;
b[a[2][2] - 'A']++;
for(int k = 0; k <= 27; k ++)
{
if(b[k] == 2)
{
for(int g = 0; g <= 27; g ++)
{
if(b[g] == 1){
int a = k, b = g;
if(a > b)swap(a,b);
anss.push_back({a,b});
}
}
}
}
memset(b,0,sizeof b);
b[a[0][2] - 'A']++;
b[a[1][1] - 'A']++;
b[a[2][0] - 'A']++;
for(int k = 0; k <= 27; k ++)
{
if(b[k] == 2)
{
for(int g = 0; g <= 27; g ++)
{
if(b[g] == 1){
int a = k, b = g;
if(a > b)swap(a,b);
anss.push_back({a,b});
}
}
}
}
memset(b,0,sizeof b);
if(!ans.empty())sort(ans.begin(),ans.end());
if(!anss.empty())sort(anss.begin(),anss.end());
if(!ans.empty())ans.erase(unique(ans.begin(),ans.end()),ans.end());
if(!anss.empty())anss.erase(unique(anss.begin(),anss.end()),anss.end());
if(!ans.empty())cout << ans.size()<<endl;
else cout << 0 << endl;
if(!anss.empty())cout << anss.size()<<endl;
else cout << 0 << endl;
}