#include <iostream>
#include <algorithm>

using namespace std;

int w, h, island;
int field[13][13];
//int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
//int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, -1, 0, 1};

void dfs(int x, int y)
{
    field[y][x] = -1;

    for (int i = 0; i < 4; i++)
    {
        int nx = x + dx[i];
        int ny = y + dy[i];

        if (nx < 0 || ny < 0 || nx >= w || ny >= h)
            continue;

        if (field[ny][nx] == 1)
            dfs(nx, ny);
    }
}

int main()
{
    island = 0;

    for (int y = 0; y < 12; y++)
    {
        for (int x = 0; x < 12; x++)
        {
            cin >> field[y][x];
        }
    }

    for (int y = 0; y < 12; y++)
    {
        for (int x = 0; x < 12; x++)
        {
            if (field[y][x] == 1)
            {
                dfs(x, y);
                island++;
            }
        }
    }

    cout << island << endl;

    return 0;
}