#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main()
{
	while(1) {
		char p[14][14];
		int k = 0;

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

		for(int i = 1; i <= 12; i++) {
			for(int j = 1; j <= 12; j++) {
				cin >> p[i][j];
			}
		}

		if(cin.eof()) break;

		while(1) {
			bool nk = false;
			for(int i = 1; i <= 12; i++) {
				for(int j = 1; j <= 12; j++) {
					if(p[i][j] == '1') {
						p[i][j] = '2';
						nk = true;
						goto loop;
					}
				}
			}

			if(nk == false) break;
			loop:
			k++;

			while(1) {
				bool np = false;
				for(int i = 1; i <= 12; i++) {
					for(int j = 1; j <= 12; j++) {
						if(p[i][j] == '1' && (p[i-1][j] == '2' || p[i+1][j] == '2' || p[i][j+1] == '2' || p[i][j-1] == '2')) {
							p[i][j] = '2';
							np = true;
						}
					}
				}

				if(np == false) break;
			}
		} 
		cout << k << endl;
	}
	return 0;
}