// Arup Guha
// 5/30/2016
// Solution to 2018 March USACO Bronze Problem: Team Tic Tac Toe

import java.util.*;
import java.io.*;

public class tttt {

	public static char[][] grid;

	public static void main(String[] args) throws Exception {

		// Read in the grid.
		Scanner stdin = new Scanner(new File("tttt.in"));
		grid = new char[3][];
		for (int i=0; i<3; i++)
			grid[i] = stdin.next().toCharArray();

		// Solve and output!
		PrintWriter out = new PrintWriter(new FileWriter("tttt.out"));
		out.println(solveOne());
		out.println(solveTwo());
		out.close();
		stdin.close();
	}

	// Return how many individual cows win.
	public static int solveOne() {
		int res = 0;
		for (int i=0; i<26; i++)
			if (win(""+(char)('A'+i)))
				res++;
		return res;
	}

	// Return how many pairs of cows win.
	public static int solveTwo() {
		int res = 0;
		for (int i=0; i<26; i++)
			for (int j=i+1; j<26; j++)
				if (win(""+((char)('A'+i))+((char)('A'+j))))
					res++;
		return res;
	}

	// Returns true iff any combo of letters in possible wins.
	public static boolean win(String possible) {

		// Check rows.
		for (int i=0; i<3; i++) {

			// Store how many of each letter show up.
			int[] freq = new int[possible.length()];
			for (int j=0; j<3; j++)
				for (int k=0; k<possible.length(); k++)
					if (possible.charAt(k) == grid[i][j])
						freq[k]++;

			// Check each frequency and total.
			int tot = 0;
			boolean ok = true;
			for (int j=0; j<freq.length; j++) {
				if (freq[j] == 0) ok = false;
				tot += freq[j];
			}

			// This is when we are okay.
			if (ok && tot == 3) return true;
		}

		// Check cols.
		for (int j=0; j<3; j++) {

			// Store how many of each letter show up.
			int[] freq = new int[possible.length()];
			for (int i=0; i<3; i++)
				for (int k=0; k<possible.length(); k++)
					if (possible.charAt(k) == grid[i][j])
						freq[k]++;

			// Check each frequency and total.
			int tot = 0;
			boolean ok = true;
			for (int i=0; i<freq.length; i++) {
				if (freq[i] == 0) ok = false;
				tot += freq[i];
			}

			// This is when we are okay.
			if (ok && tot == 3) return true;
		}

		// Forward diagonal.
		int[] freq = new int[possible.length()];
		for (int i=0; i<3; i++)
			for (int k=0; k<possible.length(); k++)
				if (possible.charAt(k) == grid[i][i])
					freq[k]++;

		int tot = 0;
		boolean ok = true;
		for (int j=0; j<freq.length; j++) {
			if (freq[j] == 0) ok = false;
			tot += freq[j];
		}

		// This is okay.
		if (ok && tot == 3) return true;

		// Backward diagonal
		freq = new int[possible.length()];
		for (int i=0; i<3; i++)
			for (int k=0; k<possible.length(); k++)
				if (possible.charAt(k) == grid[2-i][i])
					freq[k]++;

		tot = 0;
		ok = true;
		for (int j=0; j<freq.length; j++) {
			if (freq[j] == 0) ok = false;
			tot += freq[j];
		}

		// Or this...
		if (ok && tot == 3) return true;

		// If we get here we didn't win.
		return false;
	}
}