#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>


#define CI cin >>
#define CO cout <<
#define E << endl;
#define F(i,max) (for(int i = 0;i < max;++i))

using namespace std;

char board[14][14];

int dx[4] = { -1, 0, 1, 0 };
int dy[4] = { 0, -1, 0, 1 };

int JudgeSurround(int x, int y) {
	board[x][y] = '0';
	for (int k = 0; k < 4; ++k) {
		int nx = x + dx[k];
		int ny = y + dy[k];

		if (nx < 1 || 12 < nx) continue;
		if (ny < 1 || 12 < ny) continue;
		if (board[nx][ny] != '1') {
			continue;
		}
		else {
			JudgeSurround(nx, ny);
		}
	}
	return 0;
}


int main(void) {
	int count = 0;
	int end = 0;
	bool flag = false;

	for (int i = 0; i < 14; ++i) {
		for (int j = 0; j < 14; ++j) {
			board[i][j] = '0';
		}
	}


	while (true) {
		count = 0;
		end++;

		for (int i = 1; i < 13; ++i) {
			for (int j = 1; j < 13; ++j) {
				CI board[i][j];
				if (/*!(CI board[i][j])*/end == 3) {
					flag  = true;
				}
			}
		}

		for (int i = 1; i < 13; ++i) {
			for (int j = 1; j < 13; ++j) {
				if (board[i][j] == '1') {
					count++;
					JudgeSurround(i, j);
				}
			}
		}

		CO count E

		if (flag == true) {
			return 0;
		}
	}

	return 0;
}