import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    private static int[] ONE_ROWS = { 0, 1, 0};
    private static int[] TWO_ROWS = { 1, 0, 1};
    private static int[] THREE_ROWS = { 1, 1, 1};
    private static int[] FOUR_ROWS = { 2, 0, 2};
    private static int[] FIVE_ROWS = { 2, 1, 2};
    private static int[] SIX_ROWS1 = { 3, 0, 3};
    private static int[] SIX_ROWS2 = {2, 2, 2};

    private static int[] ONE_COLS = { 0, 1, 0};
    private static int[] TWO_COLS = { 1, 0, 1};
    private static int[] THREE_COLS = { 1, 1, 1};
    private static int[] FOUR_COLS = { 2, 0, 2};
    private static int[] FIVE_COLS = { 2, 1, 2};
    private static int[] SIX_COLS1 = {2, 2, 2};
    private static int[] SIX_COLS2 = { 3, 0, 3};


    public static void main(String[] args) throws IOException {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            String first = reader.readLine();
            String second = reader.readLine();
            String third = reader.readLine();
            int r1 = countDotsRow(first);
            int r2 = countDotsRow(second);
            int r3 = countDotsRow(third);

            int c1 = countDotsColumn(first, second, third, 0);
            int c2 = countDotsColumn(first, second, third, 1);
            int c3 = countDotsColumn(first, second, third, 2);

            int[] possibleNumberRow = {r1, r2, r3};
            int[] possiblenumberCol = {c1, c2, c3};
            if (Arrays.equals(possibleNumberRow, ONE_ROWS) && Arrays.equals(possiblenumberCol, ONE_COLS)) {
                System.out.println(1);
            } else if (Arrays.equals(possibleNumberRow, TWO_ROWS) && Arrays.equals(possiblenumberCol, TWO_COLS)) {
                System.out.println(2);
            } else if (Arrays.equals(possibleNumberRow, THREE_ROWS) && Arrays.equals(possiblenumberCol, THREE_COLS)) {
                System.out.println(3);
            }  if (Arrays.equals(possibleNumberRow, FOUR_ROWS) && Arrays.equals(possiblenumberCol, FOUR_COLS)) {
                System.out.println(4);
            } else if (Arrays.equals(possibleNumberRow, FIVE_ROWS) && Arrays.equals(possiblenumberCol, FIVE_COLS)) {
                System.out.println(5);
            } else if (Arrays.equals(possibleNumberRow, SIX_ROWS1) && Arrays.equals(possiblenumberCol, SIX_COLS1)
                    || Arrays.equals(possibleNumberRow, SIX_ROWS2) && Arrays.equals(possiblenumberCol, SIX_COLS2)) {
                System.out.println(6);
            }else {
                System.out.println("unknown");
            }
        }

    }

    private static int countDotsRow(String line) {
        int count = 0;
        for (char c : line.toCharArray()) {
            if (c == 'o') {
               count++;
            }
        }
        return count;
    }

    private static int countDotsColumn(String line1, String line2, String line3, int column) {
        int count = 0;
        if (line1.charAt(column) == 'o') {
            count++;
        }
        if (line2.charAt(column) == 'o') {
            count++;
        }
        if (line3.charAt(column) == 'o') {
            count++;
        }
        return count;
    }
}
