/*
枚举所有可行行
*/
#include <iostream>
#include <cstring>
#include <map>
using namespace std;
int a, b; // a 单 b 双
char s[10];
int cnt[256];
bool choose[256], choose2[256][256];
// 一共 8 种
// 0 1 2
// 3 4 5
// 6 7 8
int q[][3] = {
{0,1,2}, {3,4,5}, {6,7,8},
{0,3,6}, {1,4,7}, {2,5,8},
{0,4,8}, {2,4,6}
};
int main() {
for (int i = 0; i < 3; i++) scanf("%s", s + i * 3);
for (int i = 0; i < 8; i++) {
char c = 0, d = 0;
memset(cnt, 0, sizeof cnt);
// 计数
for (int j = 0; j < 3; j++) cnt[s[q[i][j]]]++;
for (int j = 0; j < 3; j++) {
char &t = s[q[i][j]];
// 等于 3,一定是一个人,需要判断是否选过
if (cnt[t] == 3 && !choose[t]) choose[t] = true, a++;
// 等于 2,存下
else if(cnt[t] == 2) c = t;
// 等于 1,存下
else if (cnt[t] == 1) d = t;
}
// 如果有 1 和 2,判断是否选过
if (c && d && !choose2[c][d]) choose2[c][d] = choose2[d][c] = true, b++;
}
printf("%d\n%d", a, b);
return 0;
}