/*#include<map>
#include<list>
#include<cmath>
#include<stack>
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;

int A[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int cunt = 0;

void depth(int n, int s, int i){
	
	if (n == 0 && s == 0){
		cunt++;
		return;
	}
	else if (n == 0) return;
	else if (s < 0) return;
	else if (i == 10) return;


	depth(n - 1, s - A[i],i+1);
	depth(n, s, i+1);

}

int main(){
	int n, s;
	while (cin >> n >> s){
		if (n == 0 && s == 0) break;
		depth(n, s, 0);
		cout << cunt << endl;
		cunt = 0;
	}
	return 0;
}
*/
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<cmath>
#include<string>
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

int tmap[12][12];

void Terrain(int i,int l){

	if (i<0 || i>11 || l<0 || i>11 || tmap[i][l] == 0){
		return;
	}
	tmap[i][l] = 0;

	Terrain(i + 1, l);
	Terrain(i - 1, l);
	Terrain(i, l + 1);
	Terrain(i, l - 1);

}

int main(){
	int cunt = 0;
	for (int c = 0; c < 3; c++){
		for (int i = 0; i < 12; i++){
			for (int l = 0; l < 12; l++){
				scanf_s("%1d", &tmap[i][l]);
			}
		}
		for (int i = 0; i < 12; i++){
			for (int l = 0; l < 12; l++){
				if (tmap[i][l] == 1){
					Terrain(i, l);
					cunt++;
				}
			}
		}
		cout << cunt << endl; 
		cunt = 0;
	}
	return 0;
}