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



int main(){
	string a;

	for(;;){
		//if(a == "NULL") break;
		//		b= "000000000000";
		int map[12][12]={2},flag[12][12]={0};
		int adjoin[50][50] = {0};
		//string linemap;
	

		//if(!fscanf(stdin,"%1d",&map[0][0])) break;
		//cout << map[0][0] <<endl;
		for(int i=0;i<12;i++){
			//map[0][i] = a[i];
			for(int j=0;j<12;j++){
				//if(i == j == 0) continue;
				fscanf(stdin,"%1d",&map[i][j]);
			}
		}
		//cout << map[0][0] << endl;
		//if(map[0][0]==2) break;
//		cout << map[0][2] << map[3][4] << endl;
//		cout << endl;

		int count = 0;
		//Æè ¦¸¶Æãª éÈçêv³¹é
		for(int i=0;i<12;i++){
			for(int j=0;j<12;j++){
				if(map[i][j] == 1){
					if(j>0 && map[i][j-1]==1){
						flag[i][j] = flag[i][j-1];
					}
					else if(i>0 && map[i-1][j]==1){
						flag[i][j] = flag[i-1][j];
					}
					else{
						flag[i][j] = ++count;
						//	count++;
					}
				}
			}
		}

		//ÔÌ×ÚÖWðmF
		for(int i=0;i<11;i++){
			for(int j=0;j<12;j++){
				//cout << map[i][j];
//				if(map[i][j] == 1){
					if(map[i][j]*map[i+1][j] != 0 && flag[i][j]!=flag[i+1][j]){
						//					adjoin[flag[i][j]][flag[i+1][j]] = 1;
						if(adjoin[flag[i][j]][flag[i+1][j]] == 0){
							//cout << count << " " << i <<" " << j << endl;
							--count;
							adjoin[flag[i][j]][flag[i+1][j]] = 1;
						}
					}
				//}
			}
		}

		/*for(int i=0;i<12;i++){
			for(int j=0;j<12;j++){
				cout << flag[i][j] << " " ;
			}
			cout << endl;
		}*/
		//cout << endl;
		if(!count) break;
		cout << count << endl;

	}
}