#include<iostream>
#include<fstream>
using namespace std;

const int n=34;
int col[n][n][n] = {};

void colour(int a, int b, int c, int colour)
{
    col[a][b][c] = colour;
    col[a][c][b] = colour;
    col[b][a][c] = colour;
    col[b][c][a] = colour;
    col[c][a][b] = colour;
    col[c][b][a] = colour;
}

void readfile()
{
    ifstream file;
    file.open("result.txt");
    for (int a=1; a<=11; a++)
    for (int b=a+1; b<=22; b++)
    {
        char c;
        file >> c;
        for (int d=0; d<n; d++)
            if (c=='0')
                colour((0+d)%n , (a+d)%n, (b+d)%n, 0);
            else
                colour((0+d)%n , (a+d)%n, (b+d)%n, 1);
    }
    file.close();
}

int K4(int c)
{
    int res = 0;
    for (int x1=0; x1<n; x1++)
    for (int x2=x1+1; x2<n; x2++)
    for (int x3=x2+1; x3<n; x3++)
    if (col[x1][x2][x3] == c)
        for (int x4=x3+1; x4<n; x4++)
        if (col[x1][x2][x4] == c && col[x1][x3][x4] == c && col[x2][x3][x4] == c)
        {
            res++;
        }
    return res;
}

int K5(int c)
{
    int res = 0;
    for (int x1=0; x1<n; x1++)
    for (int x2=x1+1; x2<n; x2++)
    for (int x3=x2+1; x3<n; x3++)
    if (col[x1][x2][x3] == c)
        for (int x4=x3+1; x4<n; x4++)
        if (col[x1][x2][x4] == c && col[x1][x3][x4] == c && col[x2][x3][x4] == c)
            for (int x5=x4+1; x5<n; x5++)
            if (col[x1][x2][x5] == c && col[x1][x3][x5] == c && col[x1][x4][x5] == c &&
                col[x2][x3][x5] == c && col[x2][x4][x5] == c && col[x3][x4][x5] == c)
            {
                res++;
            }
    return res;
}

int main()
{
    readfile();
    cout << "Number of K5's in colour 0: " << K5(0) << endl;
    cout << "Number of K4's in colour 1: " << K4(1) << endl;
    return 0;
}
